Question

When writing an MSBuild file from scratch, is it possible to build .csproj files directly without a reference to the solution they're a member of? Introductory guides like this one often explain how to compile individual .cs files or build a .csproj directly from the command line.

For example, command line MSBuild without a .sln reference:

msbuild helloworld.csproj /t:Build /verbosity:detailed

Or a .csproj given a .sln:

<MSBuild
  Projects="mysolution.sln"
  Targets="My_Project_File"
  Properties="Configuration=$(Configuration);Platform=$(Platform)"
  ContinueOnError="false" />

I haven't found any references mentioning building the .csproj within an MSBuild file without a .sln. Is there a way and I'm just missing something?

Was it helpful?

Solution

There is nothing wrong whatsoever with building csproj files without a solution:

<MSBuild Projects="my_project.csproj" Targets="Build" />

moreover, when you build a solution with Visual Studio what it actually does internally is convert the solution file to an msbuild script that contains a line like the above to build the projects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top