문제

I'm attempting to build a WP7 solution file form the command line using MSBuild (the solution file builds perfectly fine inside 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="&quot;$(SolutionDir)Tools\nuget.exe&quot; install &quot;$(ProjectDir)packages.config&quot; -o &quot;$(SolutionDir)Packages&quot;" />
</Target>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top