如何“摆脱"从Visual Studio外部构建Visual Studio项目时的$(SolutionDir) [英] How to "get rid of" $(SolutionDir) when building Visual Studio project from outside Visual Studio
问题描述
我想通过Visual Studio外部的MSBuild构建.vcxproj.问题在于,.vcxproj文件中有很多$(SolutionDir)出现,显然只有在加载解决方案时才能正确设置.
I want to build a .vcxproj via MSBuild from outside Visual Studio. The problem is that there are many occurrences of $(SolutionDir) inside the .vcxproj file which apparently only get set correctly when the solution is loaded.
当我用实际的绝对路径替换$(SolutionDir)时,它可以工作.但是其他计算机上的其他人正在使用相同的项目文件,因此这不是解决方案.
When I replace $(SolutionDir) with the actual absolute path, it works. But other people on other machines are working with the same project file, so this is not a solution.
是否有解决方案或黑客解决方案来解决此问题?
Is there a solution or hack to solve this problem?
推荐答案
您可以通过传递参数实参来设置变量:
You can set the variable by passing parameter arguments:
/p:SolutionDir=path
因此,您无需编辑解决方案文件,而是可以创建一个构建脚本来设置环境并相应地执行MSBuild,而将Visual Studio文件留作开发工作.
So, rather than editing the solution file, you can create a build script that sets up the environment and executes MSBuild accordingly, leaving the Visual Studio file as is for development work.
这篇关于如何“摆脱"从Visual Studio外部构建Visual Studio项目时的$(SolutionDir)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!