Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在MSBuild脚本中使用自定义变量?_Msbuild - Fatal编程技术网

如何在MSBuild脚本中使用自定义变量?

如何在MSBuild脚本中使用自定义变量?,msbuild,Msbuild,使用MSBuild.exe生成时,是否有方法在命令行上使用自定义变量,如下所示: MSBuild.exe bootstrapper.msbuild <custom_variable1=custom_variable_value1> custom_variable2=custom_variable_value2>...<custom_variablen=custom_variable_valuen> MSBuild.exe bootstrapper.MSBuild

使用MSBuild.exe生成时,是否有方法在命令行上使用自定义变量,如下所示:

MSBuild.exe bootstrapper.msbuild <custom_variable1=custom_variable_value1>

custom_variable2=custom_variable_value2>...<custom_variablen=custom_variable_valuen>
MSBuild.exe bootstrapper.MSBuild
自定义变量2=自定义变量值2>。。。

目的是了解是否必须启动另一个可执行文件。

您应该从基本知识开始。答案可以在中找到

MSBuild调用这些
属性
,而不是变量

实际上:

msbuild bootstrapper.msbuild /p:custom_variable1=custom_variable_value1
在MSBuild文件中,您可以这样使用它:

<Target Name="MyTarget">
  <PropertyGroup>
    <custom_variable1 Condition="'$(custom_variable1)'==''">defaultValue</custom_variable1>
  </PropertyGroup>
  <Exec Condition="'$(custom_variable1)'=='someValue'" .../>
</Target>

默认值

如果属性不存在或为空,则为其指定默认值,如果该值等于
someValue

则仅执行
Exec
任务这正是我想要的答案<代码>$(SolutionName)在加载项目时似乎失败,因此我必须在“执行”期间进行检查