简体   繁体   English

由于缺少属性文件,MSBuild 无法构建 Visual Studio 项目(可能与 IDE 相关)

[英]MSBuild fails to build Visual Studio Project due to missing property files (potentially IDE related)

I'm trying to get Jenkins running in a docker windows container and I've got most everything set up but I continue to run into a compilation error:我试图让 Jenkins 在 docker windows 容器中运行,并且我已经完成了大部分设置,但我继续遇到编译错误:

22:21:06 C:\JENKINS_HOME\workspace\iCEWav\src\engine\IceLibrary\IceLibrary.vcxproj(27,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

I installed MSBuild using this command:我使用以下命令安装了 MSBuild:

RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
--remove Microsoft.VisualStudio.Component.Windows81SDK `
--installPath C:\BuildTools

It looks like the Visual Studio Project that I created in Visual Studio Community looks for a properties file here:看起来我在 Visual Studio Community 中创建的 Visual Studio 项目在这里寻找一个属性文件:

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

This builds fine on the local machine where the project was created but the file is missing in the docker container.这在创建项目的本地计算机上构建良好,但 docker 容器中缺少该文件。 I'm wondering if these files are generated once the IDE runs the first time or am I missing a step here?我想知道这些文件是在 IDE 第一次运行后生成的,还是我在这里遗漏了一步?

So my boiled down question... Can I compile a Visual Studio Project File using only Visual Studio BuildTools?所以我归结为问题......我可以只使用 Visual Studio BuildTools 编译 Visual Studio 项目文件吗? If so, how do I generate or ignore these property files.如果是这样,我如何生成或忽略这些属性文件。

Well that didn't take too long.好吧,这并没有花太长时间。 According to documentation , MSBuild is actually not apart of the recommended or required workload for VCTools.根据文档,MSBuild 实际上不属于 VCTools 推荐或要求的工作负载。 The MSBuild that was already on the Docker container came from the base image provided by Micosoft and lacked the VC tools (mcr.microsoft.com/dotnet/framework/sdk:4.7.2-windowsservercore-ltsc2019).已经在 Docker 容器上的 MSBuild 来自 Micosoft 提供的基本映像,并且缺少 VC 工具 (mcr.microsoft.com/dotnet/framework/sdk:4.7.2-windowsservercore-ltsc2019)。

I modified the install command to include MSBuild which ultimately downloaded the VC directories needed.我修改了安装命令以包含 MSBuild,它最终下载了所需的 VC 目录。

RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--channelUri C:\TEMP\VisualStudio.chman `
--installChannelUri C:\TEMP\VisualStudio.chman `
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended`
--add Microsoft.Component.MSBuild `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
--remove Microsoft.VisualStudio.Component.Windows81SDK `
--installPath C:\BuildTools

This installed the necessary files.这安装了必要的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM