问题
I am customizing Default Template to Auto update the Production version and Product code of Install Shield project during the build. Which is working fine in local machine?
But through TFS Build it’s giving an exception as
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)
My TFS Build server is 64 Bit server. And below is Custom Activity code:
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();
}
}
}
}
}
I looked at below links also but no success:
http://community.flexerasoftware.com/showthread.php?195743-Integrating-Installshield-2011-with-Team-Foundation-Server-(TFS)-2010&p=464354#post464354
Any help regarding the same would be much helpful for me. Thanks!!
@Update Alternative Solution
Thanks Chris!!
As per your instruction i used MS Build FunctionPropertise to achieve this.
Here is my .ISPORJ file
<PropertyGroup>
<InstallShieldProductVersion>$(ProductVersion)</InstallShieldProductVersion>
</PropertyGroup>
<ItemGroup>
<InstallShieldPropertyOverrides Include="{$([System.Guid]::NewGuid().ToString().ToUpper())}">
<Property>ProductCode</Property>
</InstallShieldPropertyOverrides>
</ItemGroup>
The ProductVersion I’m passing through MSbuild Arguments from Team Build.
回答1:
InstallShield supports MSBuild. MSBuild now supports Property Functions (properties that get there value by calling static methods on .NET classes ). This means it's now easy to gen up a GUID and assign it to ProductCode.
InstallShield does require the 32-bit MSBuild platform and this can be configured via the build definition parameters.
It is possible to fully automate an InstallShield build using just the default build process template. No custom workflow development is required. Custom MSBuild tasks calling the InstallShield Automation Interface isn't required either.
Please feel free to email me if you'd like a screen sharing session to walk you through it.
回答2:
Do you have InstallShield SDK or whatever the product is called installed on the build server like you do on your dev machine?
回答3:
Team Build by default runs a 64-bit process, unless you install it on a Windows 8 32-bit client. That will probably allow you to resolve your issue. You must install InstallShield on the Build Agent as well.
Alternatively, create a x86 command line executable containing the logic in your activity. From the Custom Activity invoke the command line utility and supply the parameters from the activity to the console application using commandline parameters.
来源:https://stackoverflow.com/questions/20951003/upgrading-tfs-build-template-to-automate-installed-shield-project