locked
Sharing project properties in a large C# solution RRS feed

  • Question

  • I have several C# projects (over 100) which are combined in various combinations to create a solution (about 30 projects each.)  Is there any way to share the project property settings such as Output Path and CLR Version among all the projects in the solution so I don't have to update all the projects separately?

    Thanks In Advance,

    Tony

    Thursday, October 15, 2015 4:02 PM

Answers

  • Personally I'd use the VS API to adjust all the project settings because I cannot imagine that it happens that often.  Powershell in combination with the VS API (or perhaps even straight XML manipulation) will do the trick.

    For things like output path note that VS uses a macro for the output directory and you can technically set it to anything you want.  That is exactly how TFS builds your solution.  If you use automated builds or otherwise only care about the path during specific builds then override the $(OutputDir) macro.  Refer to the command line options of MSbuild on how to do that. Alternatively you can use an environment variable if you wanted all projects to build to the same output but that seems a little odd.

    For other settings you need to be a little careful if it impacts the runtime behavior. For example changing the CLR version isn't simply a project change. You also need to update the config file to include the new CLR version and assembly references can potentially change as well. For example moving from v2 to v4 requires that you add new assemblies but if you step back then need to be removed.  Also keep in mind that many Nuget packages are installed based upon the framework in use at the time.  Many of them will need to be updated or reinstalled so they target the updated framework version.  When you change the version in VS it will display a warning about these packages but doing it programmatically will be trickier.

    Michael Taylor
    http://blogs.msmvps.com/p3net

    • Proposed as answer by Kristin Xie Monday, October 19, 2015 6:58 AM
    • Marked as answer by Kristin Xie Monday, October 26, 2015 1:59 AM
    Thursday, October 15, 2015 6:37 PM

All replies

  • Tony,

    No there isn't. There might be a VS extension that might do it. I would recommend searching to see if someone wrote one.

    David

    Thursday, October 15, 2015 5:58 PM
  • I have seen solutions where there were over 100 or more projects in a single solution, and there was nothing to allow projects to share project properties.  So, I would say the answer is no.

     
    Thursday, October 15, 2015 6:06 PM
  • Personally I'd use the VS API to adjust all the project settings because I cannot imagine that it happens that often.  Powershell in combination with the VS API (or perhaps even straight XML manipulation) will do the trick.

    For things like output path note that VS uses a macro for the output directory and you can technically set it to anything you want.  That is exactly how TFS builds your solution.  If you use automated builds or otherwise only care about the path during specific builds then override the $(OutputDir) macro.  Refer to the command line options of MSbuild on how to do that. Alternatively you can use an environment variable if you wanted all projects to build to the same output but that seems a little odd.

    For other settings you need to be a little careful if it impacts the runtime behavior. For example changing the CLR version isn't simply a project change. You also need to update the config file to include the new CLR version and assembly references can potentially change as well. For example moving from v2 to v4 requires that you add new assemblies but if you step back then need to be removed.  Also keep in mind that many Nuget packages are installed based upon the framework in use at the time.  Many of them will need to be updated or reinstalled so they target the updated framework version.  When you change the version in VS it will display a warning about these packages but doing it programmatically will be trickier.

    Michael Taylor
    http://blogs.msmvps.com/p3net

    • Proposed as answer by Kristin Xie Monday, October 19, 2015 6:58 AM
    • Marked as answer by Kristin Xie Monday, October 26, 2015 1:59 AM
    Thursday, October 15, 2015 6:37 PM