Search code examples
msbuildpublish-profiles

When publishing solution, is it possible to ignore certain projects?


We have some projects that are only used in some environments so I would like publishing to skip them. However, when publishing the whole solution I get the following msbuild error:

"C:\Source\Solution.sln" (default target) (1) ->
"C:\Source\Project\Project.csproj" (default target) (51) ->
(ValidatePublishProfileSettings target) ->
  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4253,5): error : The value for PublishProfile is set to 'Sta
ge', expected to find the file at 'C:\Source\Project\Properties\PublishProfiles\Stage.pubxml' but it could not be found. [C:\Source\Project\Project.csproj]
  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4260,4): error : PublishProfile(Stage) is set. But the $(Web
PublishMethod) does not have a valid value.  Current Value is "". [C:\Source\Project\Project.csproj]
  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4267,5): error : Target ValidatePublishProfileSettings Faile
d [C:\Source\Project\Project.csproj]

Is there any way to ignore the project when publishing the solution so I don't get build errors?


Solution

  • I'd go with:

    1. a custom build srcript (call msbuild individually for every project that you want to publish) (my preferred option hence it gives you much more flexibility)
    2. a custom .sln file with only needed projects for the sole purpose of publishing (easier option, but harder to maintain)

      3.Just a wild guess(never tried this for deployment, but should work based on my understanding) - you could try using Build -> Configuration Manager dialog in VS to uncheck build checkboxes for certain projects if you can go with creating separate solution configurations for separate deployment plans: configuration manager