Visual Studio 2013 和 MSBuild 命令行开关

Visual Studio 2013 和 MSBuild 命令行开关

问题描述:

有没有办法在 Visual Studio 2013 中指定像/p:option=value 这样的 msbuild 开关?

Is there a way to specify msbuild switches like /p:option=value within Visual Studio 2013?

从上面正式化我的评论.

Formalizing my comment from above.

一个可能的解决方案可能是拥有一个定义要覆盖的属性及其值的目标文件(例如 VisualStudioOverrides.targets).然后,如果此文件存在,则 csproj 文件将导入它,从而覆盖相关属性.这样的导入语句应该放在 csproj 文件的底部(在定义要覆盖的属性之后)并且看起来像:

A possible solution may be to have a targets file (e.g. VisualStudioOverrides.targets) that defines the properties to be overridden and their values. Then, if this file exists then the csproj file will import it, thus override the relevant properties. Such an import statement should be placed at the bottom of the csproj file (after the properties to be overridden were defined) and would look something like:

<Import Project="$(MSBuildProjectDirectory)\VisualStudioOverrides.targets" Condition="Exists('$(MSBuildProjectDirectory)\VisualStudioOverrides.targets')" />