I'm attempting to build a WP7 solution file form the command line using MSBuild (the solution file builds perfectly fine inside 开发者_StackOverflow社区VS). So far I have the following:
msbuild Test.WP7.sln /t:rebuild /p:OutputPath="bin\Release" /p:Platform="Any CPU" /p:Configuration="Release"
The problem I am having is a pre build step to install any NuGet packages required, the tool is reference by relative directory different from the solution file:
..\Tools\NuGet\nuget install $(ProjectDir)packages.config -o $(SolutionDir)Packages
Now when run from the command line MSBuild can't find this directory and returns a MSB3073 error like:
"C:\Work\test\trunk\test\test.WP7.sln" (rebuild target) (1) -> "C:\Work\test\trunk\test\test.Core.View.ViewModel\test.Core.View.ViewModel.csproj" (Rebuild target) (4) -> c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(902,9): error MSB3073: The command "..\Tools\NuGet\nuget install C:\Work\test\trunk\test\test.Core.View.ViewModel\packages.config -o C:\Work\test\trunk\test\Packages" exited with code 3. [C:\Work\test\trunk\test\test.Core.View.ViewModel\test.Core.View.ViewModel.csproj]
Any ideas how I can get round this without changing the project or solution files?
Don't use a relative path for NuGet. Instead use the $(SolutionDir)
variable, like this:
<Target Name="BeforeBuild">
<Exec Condition="Exists('$(ProjectDir)packages.config')"
Command=""$(SolutionDir)Tools\nuget.exe" install "$(ProjectDir)packages.config" -o "$(SolutionDir)Packages"" />
</Target>
精彩评论