4

You can use the Property Manager window in Visual Studio for managing common properties of C++ projects, but there appears to be no equivalent to this for C# projects.

Is there a way to set common settings across multiple projects? Examples of things I'd like to do:

  • add TEST preprocessor directive for all projects that have a TEST build configuration
  • change warnings to errors for all C# projects
  • add a reference to some common assembly for N selected C# projects at once
  • etc.

A plugin, macro, or extension would all be acceptable.

Community
  • 1
  • 1
Kit
  • 20,354
  • 4
  • 60
  • 103
  • No equivalent, mostly because C# projects have blessedly few configurable items. You are thinking like a C++ programmer, not the best way to get started with C#. You can get what you want by editing the .vcproj files by hand, use `` – Hans Passant Aug 04 '11 at 16:30
  • 1
    I'm far from getting started with C# and, alas, global regex replace on .csproj files has been my solution so far. That's not fun. – Kit Aug 05 '11 at 01:27

3 Answers3

1

There is no a real equivalent of Property Manager for C# projects. However, if the goal is to share common settings across multiple projects, you can create a NuGet package with .props file defining the shared properties and reference it in your C# projects - VS will automatically import it at build time.

.props and .targets inclusion is supported as of NuGet 2.x. Tip: make sure the .props file name matches the NuGet package id, otherwise it won't be included. You can see an example here.

Gryff
  • 26
  • 2
1

You can customize the C# project template for Visual Studio, so that every time you create a new project it has all the settings you want.

http://msdn.microsoft.com/en-us/library/6db0hwky.aspx

http://www.a2zdotnet.com/View.aspx?Id=170

dbugger
  • 15,868
  • 9
  • 31
  • 33
  • For new projects this is indeed useful. I'm looking for a solution to applying changes across existing projects. – Kit Aug 05 '11 at 01:28
  • Project files are xml. If you want to clean up existing files, you can write up a little app that rips through them and puts in the nodes you want. – dbugger Aug 05 '11 at 01:38
  • Hm. This has me thinking... Could I use VS's web.config transform functionality? A separate sln that includes .csproj files as content, not projects and use the transform rules to change the files. Then the "real" sln picks these up...? – Kit Aug 05 '11 at 01:54
  • Sounds like you would be fighting a lot of built-in VS convention to make that work. A stand alone console app would be less fraught with making VS do unnatural things. Just tell it where to look for the project files, suck them in and do your dirty work. – dbugger Aug 05 '11 at 17:05
0

The closest equivalent is currently using regex from within VS on an unloaded project or writing something to process the msbuild xml backing the .csproj files.

Kit
  • 20,354
  • 4
  • 60
  • 103