ans*_*iwn 7 tfs wix tfsbuild tfs2010
我一直试图找到我的问题的答案,但却找不到; 因此我会在这里提出解决方案.我希望它对其他人有所帮助.
我希望我的Wix项目能够在TFS 2010构建过程中构建.作为其中的一部分,我希望我的Wix的源文件位置指向TFS的构建位置.例如,我想:
<File Id="ABC" KeyPath="yes" source="C:\Builds\1\MyBuild\assembly.dll" />
Run Code Online (Sandbox Code Playgroud)
成为:
<File Id="ABC" KeyPath="yes" source="$(var.TFSLOCATION)\assembly.dll" />
Run Code Online (Sandbox Code Playgroud)
'TFSLOCATION'是一个wix属性,需要填充TFS构建的位置.这需要在构建过程中发生,其中构建位置路径被传递给Wix项目.
我读了以下文章:
http://www.ageektrapped.com/blog/setting-properties-for-wix-in-msbuild/
这就是我对我的Wix项目文件(wixproj)所做的:
为了从TFS MSBuild进程设置wix属性,wix项目文件需要两个更改:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ProductVersion>3.5</ProductVersion>
<SourceLocation Condition="'$(SourceLocation)' == '' ">UNKNOWN</SourceLocation>
<ProjectGuid>{cae7e273-2de5-4a60-9c4f-9da5f094caf5}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>N4S.MSO.BAM.Installer</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>LOCATION=$(SourceLocation)</DefineConstants>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
在上面的xml中,请注意以下两行:
<SourceLocation Condition="'$(SourceLocation)' == '' ">UNKNOWN</SourceLocation>
<DefineConstants>LOCATION=$(SourceLocation)</DefineConstants>
Run Code Online (Sandbox Code Playgroud)
第一行指定属性"SourceLocation"并将其设置为默认的"UNKNOWN"值(如果未设置).第二行在'Release'配置中定义了一个名为'LOCATION'的常量.此常量的值设置为"SourceLocation"属性的值.
现在,您需要对Product.wxs文件(或wxs文件的任何名称)进行以下更改.
<?define TFSLOCATION="$(var.LOCATION)"?>
Run Code Online (Sandbox Code Playgroud)
<File Id="ABC" KeyPath="yes" source="$(var.TFSLOCATION)\assembly.dll" />
Run Code Online (Sandbox Code Playgroud)
String.Format("/p:SourceLocation={0}", BinariesDirectory)
Run Code Online (Sandbox Code Playgroud)
您现在已经从TFS构建过程填充了一个wix属性.
如果在wixproj文件中将引用设置为正在构建的项目,则可以引用其目标路径.因此,如果您有两个项目MyProject和MyProjectInstaller,请在MyProjectInstaller中将引用设置为MyProject.
现在在product.wxs文件中,您的File元素将如下所示:
<File Id='EXE' Name='$(var.MyProject.TargetDir)\MyProject.exe' />
<File Id='DLL' Name='$(var.MyProject.TargetDir)\MyProject.dll' />
...
Run Code Online (Sandbox Code Playgroud)
这样做的好处是目标目录是正确的,无论您是在本地构建还是在构建服务器上构建.
| 归档时间: |
|
| 查看次数: |
5941 次 |
| 最近记录: |