试图在构建服务器上构建我的项目给我以下错误:

Microsoft (R) Build Engine Version 4.0.30319.1
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

几个月前,我通过在Build Server上安装Visual Studio 2010解决了这个问题。但是现在我从头开始安装一个新的服务器,我想知道是否有更好的解决方案来解决这个问题。


当前回答

通过NuGet添加依赖项并设置一个构建参数

目标:对构建代理没有必要的更改/安装

我在这里采用了Lloyd的NuGet方法的混合方法,该方法基于Andrik的提交二进制依赖解决方案。

原因是我希望能够添加新的构建代理,而不需要使用诸如此类的项预先配置它们。

在机器上用Visual Studio打开解决方案;忽略web项目失败。 在NuGet包管理器中,添加MSBuild.Microsoft.VisualStudio.Web。目标,正如Lloyd提到的。 这将把二进制文件解析为[solution]\packages\ msbuild . microsoft . visualstudio . web .target .nn.n.n.n\tools\VSToolsPath\ 你可以把这些复制到引用文件夹并提交, 或者就在它们所在的地方使用它们。我选择了这个,但是稍后我将不得不处理路径中的版本号。

在版本7中,我执行了以下操作。这可能是不必要的,根据评论,现在肯定不需要了。请看下面的评论。

接下来,在TeamCity构建配置中,为env添加一个构建参数。VSToolsPath并将其设置为VSToolsPath文件夹;我使用的是..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.11.0.2.1\tools\VSToolsPath

其他回答

通过NuGet添加依赖项并设置一个构建参数

目标:对构建代理没有必要的更改/安装

我在这里采用了Lloyd的NuGet方法的混合方法,该方法基于Andrik的提交二进制依赖解决方案。

原因是我希望能够添加新的构建代理,而不需要使用诸如此类的项预先配置它们。

在机器上用Visual Studio打开解决方案;忽略web项目失败。 在NuGet包管理器中,添加MSBuild.Microsoft.VisualStudio.Web。目标,正如Lloyd提到的。 这将把二进制文件解析为[solution]\packages\ msbuild . microsoft . visualstudio . web .target .nn.n.n.n\tools\VSToolsPath\ 你可以把这些复制到引用文件夹并提交, 或者就在它们所在的地方使用它们。我选择了这个,但是稍后我将不得不处理路径中的版本号。

在版本7中,我执行了以下操作。这可能是不必要的,根据评论,现在肯定不需要了。请看下面的评论。

接下来,在TeamCity构建配置中,为env添加一个构建参数。VSToolsPath并将其设置为VSToolsPath文件夹;我使用的是..\packages\MSBuild.Microsoft.VisualStudio.Web.targets.11.0.2.1\tools\VSToolsPath

这就是你所需要的。只有103 mb。不要安装所有东西

如上所述,除了针对Microsoft. webapplication .targets的“Microsoft Visual Studio 2010 Shell(集成)可重分发包”和针对Microsoft. data . schema . sqltasks .targets的“Microsoft Visual Studio Team System 2008 Database Edition GDR R2”之外,最新的Windows SDK应该可以减少安装Visual Studio 2010的需求。然而,安装VS 2010可能实际上更少的整体下载和更少的工作。

你也可以使用NuGet包MSBuild.Microsoft.VisualStudio.Web。目标,在你的Visual Studio项目中引用它们,然后按照Andriy K的建议更改你的引用。

如果你正在使用MSBuild,就像在构建服务器的情况下一样,对我来说有用的是:

修改如下:

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

to:

<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

我的Msbuild命令是:*“C:\Program Files (x86)\ Msbuild \14.0\Bin\ Msbuild .exe”方案。sln /p:Configuration=Debug /p:Platform="任意CPU"* .

希望这能帮助到一些人。