How do I target a specific .NET project within a Solution using MSBuild from VS2010?

China☆狼群 提交于 2019-12-17 22:48:38

问题


I have an MSBuild command line that can build an entire solution. It looks something like this:

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:Build

I know that for C++ Solutions, specific projects can be targeted using the following syntax:

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:Folder\SomeCppProject;Build

I'm trying to achieve the same thing for .NET projects within a solution. This does NOT work:

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:SomeDotNetProject;Build

Does anyone know how to target a specific project within a solution using MSBuild on the command line for .NET projects? I know I can create a custom MSBuild project to achieve what I'm after, but I need to share the solution and projects with Visual Studio.

Thanks!
-Sean


回答1:


You'll need to specify any solution folders in the Visual Studio solution file, and replace any "." in the project name with "_":

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /t:Folder\Project_Name

For example, if you have a project in the solution folder "Deploy" named "MyApplication.Deployment.csproj", you'll need

msbuild SomeSolution.sln /p:Configuration:CustomDebug;Platform=OurPlatform /t:Deploy\MyApplication_Deployment

Incidentially this is a solution folder, as displayed in Visual Studio, not a file system folder: those are ignored.




回答2:


You can use the following commandline for building your project using msbuild from commandline

msbuild Solution.sln /p:Configuration=Release;Platform=x86 /t:ProjectName:Rebuild



回答3:


Invoke MSBuild on the project file instead of the solution file (ref.msbuild /?)

msbuild SomeDotNetProject\SomeDotNetProject.csproj /p:Configuration:CustomDebug;Platform=OurPlatform /nodeReuse:false /maxcpucount:4 /t:Build


来源:https://stackoverflow.com/questions/6346556/how-do-i-target-a-specific-net-project-within-a-solution-using-msbuild-from-vs2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!