我将自定义默认模板以在构建过程中自动更新安装屏蔽项目的生产版本和产品代码。哪个在本地机器上正常工作?升级TFS构建模板以自动安装屏蔽项目
但通过TFS构建它给一个例外,因为
Exception Message: Retrieving the COM class factory for component with CLSID {52BA76F5-D0A7-4F2E-BD4A-45F8F2CE6A55} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). (type COMException)
我的TFS构建服务器是64位服务器。 及以下自定义活动代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Text.RegularExpressions;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;
using Microsoft.TeamFoundation.VersionControl.Client;
using ISWiAuto20;
namespace InstallShieldBuildTask.Activities
{
[BuildActivity(HostEnvironmentOption.All)]
public sealed class IncreaseProductVersion : CodeActivity
{
// The file mask of all files for which the buildnumber of the
// AssemblyVersion must be increased
[RequiredArgument]
public InArgument<string> InstallShieldFileMask { get; set; }
[RequiredArgument]
public InArgument<bool> UpdateProductVersion { get; set; }
[RequiredArgument]
public InArgument<bool> UpdateProductCode { get; set; }
// The SourcesDirectory as initialized in the Build Process Template
[RequiredArgument]
public InArgument<string> SourcesDirectory { get; set; }
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the input arguments
string sourcesDirectory = context.GetValue(this.SourcesDirectory);
string installShieldFileMask = context.GetValue(this.InstallShieldFileMask);
var updateProductVersion = context.GetValue(this.UpdateProductVersion);
var updateProductCode = context.GetValue(this.UpdateProductCode);
foreach (string file in Directory.EnumerateFiles(sourcesDirectory, installShieldFileMask, SearchOption.AllDirectories))
{
if (updateProductVersion || updateProductCode)
{
ISWiProject oISWiProj = new ISWiProject();
//Opne the file to read
oISWiProj.OpenProject(file, false);
if (updateProductVersion)
{
var currentProductVersion = oISWiProj.ProductVersion;
Version version = new Version(currentProductVersion);
Version newVersion = new Version(version.Major, version.Minor, version.Build + 1, version.Revision);
oISWiProj.ProductVersion = newVersion.ToString();
}
if (updateProductCode)
{
oISWiProj.ProductCode = oISWiProj.GenerateGUID();
}
oISWiProj.SaveProject();
oISWiProj.CloseProject();
}
}
}
}
}
我看了看下面的链接,也不过没有成功:
任何关于相同的帮助将是没什么太大的帮助我。谢谢!!
@Update 替代解决方案
感谢克里斯!
根据你的指令,我使用MS Build FunctionPropertise来实现这一点。
这是我.ISPORJ文件
<PropertyGroup>
<InstallShieldProductVersion>$(ProductVersion)</InstallShieldProductVersion>
</PropertyGroup>
<ItemGroup>
<InstallShieldPropertyOverrides Include="{$([System.Guid]::NewGuid().ToString().ToUpper())}">
<Property>ProductCode</Property>
</InstallShieldPropertyOverrides>
</ItemGroup>
我穿过的MSBuild参数从团队建设的ProductVersion。
非常感谢Christopher ...我已经用替代解决方案更新了我的问题.. –