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

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

我正在尝试将 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 Studio19\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.

我使用此命令安装了 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

我在 Visual Studio 社区中创建的 Visual Studio 项目似乎在此处查找属性文件:

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

这在创建项目的本地计算机上构建良好,但文件在 docker 容器中丢失。我想知道这些文件是在第一次 IDE 运行 时生成的,还是我在这里遗漏了一个步骤?

所以我的归结问题...我可以仅使用 Visual Studio BuildTools 编译 Visual Studio 项目文件吗?如果是这样,我该如何生成或忽略这些 属性 文件。

没花太长时间。根据 documentation,MSBuild 实际上不属于 VCTools 推荐或要求的工作负载。已经在 Docker 容器上的 MSBuild 来自 Micosoft 提供的基础映像,缺少 VC 工具 (mcr.microsoft.com/dotnet/framework/sdk:4.7.2-windowsservercore-ltsc2019 ).

我修改了安装命令以包含 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

这安装了必要的文件。