通过CI中的MSBuild.exe发布Web应用程序时,NuGet定位错误的文件夹

时间:2015-09-01 15:31:54

标签: c# msbuild continuous-integration nuget bamboo

我正在尝试在CI服务器(竹子)中设置项目。

我有一个包含多个项目的API解决方案(数据访问,服务接口,WebApi,测试,其他一些......你明白了)。我在脚本中运行nuget.exe以在解决方案级别引入必需的包。包进入解决方案目录var="country"

当我使用MSBuild创建二进制文件时,一切都很好。然后我在测试项目中使用MSTest runner;还是一切都很好。然后我关闭目标Web服务,然后使用参数.nuget对WebApi项目运行msbuild.exe

这是竹子咆哮的地方。我得到了失败错误消息:

/p:DeployOnBuild=true /p:PublishProfile=INTENV

项目显然是在项目文件夹中寻找依赖项,在这种情况下,仅在这种情况下。

如何告诉MSBuild.exe此文件夹是一级的?这是唯一让它感到困惑的地方。

1 个答案:

答案 0 :(得分:0)

So what was happening when I targeted the project instead of the solution with MSBuild.exe is that it considered $(SolutionDir) to be the project directory. It was looking for the the nuget targets at $(SolutionDir).nuget\NuGet.targets, which was an incorrect path if starting at the project level, but perfectly fine at the solution level.

On my MSBuild.exe command line, I added a parameter as follows:

/property:SolutionDir="(path of my solution)"

This did the trick.

I also tried to change the project settings, but NuGet always replaced them; the above manner is the only way I could get it to work.