尝试在构建服务器上构建个人项目会给我如下错误: 服务器
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,从而解决了这个问题。 可是如今我要从头开始安装新服务器,我想知道是否有更好的解决方案来解决此问题。 工具
根据此处的这篇文章,您能够简单地下载Microsoft Visual Studio 2010 Shell(集成)可再发行软件包,并安装目标。 ui
这避免了在生成服务器上安装Visual Studio的须要。 spa
我刚刚尝试了一下,能够验证它是否有效: 代理
以前: code
错误MSB4019:找不到导入的项目“ C:\\ Program Files(x86)\\ MSBuild \\ Microsoft \\ VisualStudio \\ v10.0 \\ WebApplications \\ Microsoft.WebApplication.targets”。 确认声明中的路径正确,而且文件在磁盘上。 图片
安装后: get
[正确构建] it
显然,这比在构建服务器上安装Visual Studio更好。 io
UPD:从VS2017开始,构建工具中的工做负载能够彻底消除此问题。 参见@SOReader答案 。
若是您不但愿在构建服务器上进行任何修改,而且仍然但愿在源代码控制以外直接构建项目,则最好将所需的二进制文件置于源代码控制下。 您须要修改项目文件中的imports部分,以下所示:
<Import Project="$(SolutionDir)\BuildTargets\WebApplications\Microsoft.WebApplication.targets" /> <Import Condition="false" Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
第一行是相对于解决方案目录的新位置的实际导入。 第二个是原始行的关闭版本( Condition="false"
),该版本容许Visual Studio仍将您的项目视为有效的Web应用程序项目(这就是VS 2010 SP1自己的技巧)。
不要忘记将C:\\Program Files (x86)\\Microsoft\\VisualStudio\\v10.0\\WebApplications
复制到源代码管理下的BuildTargets
文件夹。
您还可使用NuGet包MSBuild.Microsoft.VisualStudio.Web.targets ,在Visual Studio项目中引用它们,而后按照Andriy K的建议更改引用。
目标:无需对构建代理进行任何更改/安装
我在这里采用了Lloyd的NuGet方法的混合方法,该方法基于Andrik提交的二进制依赖项解决方案。
我之因此但愿可以添加新的构建代理,而没必要使用诸如此类的项目进行预配置,是由于。
[solution]\\packages\\MSBuild.Microsoft.VisualStudio.Web.targets.nn.nnn\\tools\\VSToolsPath\\
在版本7中,我执行了如下操做。 这可能不是必需的,而且如今绝对不须要基于注释。 请参阅下面的评论。
env.VSToolsPath
添加一个构建env.VSToolsPath
并将其设置到VSToolsPath文件夹中; 我使用了..\\packages\\MSBuild.Microsoft.VisualStudio.Web.targets.11.0.2.1\\tools\\VSToolsPath
这就是您所须要的。 只有103MB。 不要安装全部内容