在我的 Visual Studio 2010 项目中,我们在 C# 项目中运行 prebuild 和 postbuildevent,如下所示:
prebuildevent: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\rc.exe" "$(ProjectDir)$(ProjectName).rc"
postbuildevent: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" -outputresource:"$(TargetDir )$(目标文件名)";#1
其中,rc.exe 和 mt.exe 的路径是为 Visual Studio 2010 硬编码的。现在我们正在从 Visual Studio 2010 迁移到 Visual Studio 2019。
在 Visual Studio 2019 中,rc.exe 和 mt.exe 存在于以下路径中:“C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\rc.exe”和“C:\程序文件 (x86)\Windows 工具包\10\bin\10.0.17763.0\x86\mt.exe”。
但我不能使用上面提到的硬编码路径,因为 Windows SDK 版本会随着每个 SDK 版本更新而改变。
我发现我们可以使用WindowsSdkverbinpath变量来获取最新的 windows sdk 版本路径,但在我的情况下,我可以像 $(WindowsSdkverbinpath) 一样将它用于 c++ 项目,它正在解析路径和我无法的 c# 项目像在 c++ 项目中一样使用它。
搜索 WindowsSdkverbinpath 的目的是在 prebuild 和 postbuild 事件中使用它来访问 mt.exe 和 rc.exe
请任何人都可以帮助我让 WindowsSdkverbinPath 在 ac# 项目的 prebuild 和 postbuildevents 中使用它,在此先感谢。