This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Automation example in C#
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
09:24 AM
Automation example in C#
We use MS TFS to build our c# solutions. These solutions include our Installshield projects. I need to set a property in the Installshield project before the solution build. I would do this in a custom task except that all the ISWIAutomation examples seem to be in VB. We are almost completly c#.
My atempt has errors:
{
ISWiAuto12.ISWiProject pProject = new ISWiAuto12.ISWiProject();
pProject.OpenProject("C:\\temp\\iswiproperty\\testproperty1\\TestProperty1\\TestProperty1.ism", false);
ISWiAuto12.ISWiProperty pProperty = new ISWiAuto12.ISWiProperty();
pProperty = pProject.ISWIProperties["MYVERSION"];
pProperty.set_Value("3.3.1.456.0");
pProject.SaveProject();
}
Any ideas?
My atempt has errors:
{
ISWiAuto12.ISWiProject pProject = new ISWiAuto12.ISWiProject();
pProject.OpenProject("C:\\temp\\iswiproperty\\testproperty1\\TestProperty1\\TestProperty1.ism", false);
ISWiAuto12.ISWiProperty pProperty = new ISWiAuto12.ISWiProperty();
pProperty = pProject.ISWIProperties["MYVERSION"];
pProperty.set_Value("3.3.1.456.0");
pProject.SaveProject();
}
Any ideas?
(9) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
09:35 AM
As a sanity check, if you're using InstallShield 2008, perhaps use ISWiAuto14 instead of ISWiAuto12?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
09:47 AM
Actually I'm using both, but this project is a IS12 project.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
09:58 AM
I am also changing/setting some properties before compiling my project through MsBuild. I am using the FileUpdate RegEx task within MsBuild Community Tasks
Just as an example you can have a custom Target that you call before compiling:
It is essential that you specify the Encodig Property to "us-ascii". Let me know if you need more help.
Peter.
Just as an example you can have a custom Target that you call before compiling:
It is essential that you specify the Encodig Property to "us-ascii". Let me know if you need more help.
Peter.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
10:19 AM
(And as for Automation, what error do you see?)
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
10:26 AM
My references list: isappserviceslib, ismautolib, ismmupdaterlib, isupgradelib, isqiauto12, iswibuildlib.
Code:
class Program
{
static void Main(string[] args)
{
ISWiAuto12.ISWiProject pProject = new ISWiAuto12.ISWiProject();
pProject.OpenProject("C:\\temp\\iswiproperty\\testproperty1\\TestProperty1\\TestProperty1.ism", false);
ISWiAuto12.ISWiProperty pProperty = new ISWiAuto12.ISWiProperty();
pProperty = pProject.ISWIProperties["MYVERSION"];
pProperty.set_Value(ref "3.3.1.456.0");
pProject.SaveProject();
}
}
Errors;
Error 1 The type 'ISWiAuto12.ISWiPropertyClass' has no constructors defined C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 15 49 iswiproperty
Error 2 A ref or out argument must be an assignable variable C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 18 37 iswiproperty
Error 3 The best overloaded method match for 'ISWiAuto12._ISWiProperty.set_Value(ref string)' has some invalid arguments C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 18 13 iswiproperty
Error 4 Argument '1' must be passed with the 'ref' keyword C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 18 37 iswiproperty
Code:
class Program
{
static void Main(string[] args)
{
ISWiAuto12.ISWiProject pProject = new ISWiAuto12.ISWiProject();
pProject.OpenProject("C:\\temp\\iswiproperty\\testproperty1\\TestProperty1\\TestProperty1.ism", false);
ISWiAuto12.ISWiProperty pProperty = new ISWiAuto12.ISWiProperty();
pProperty = pProject.ISWIProperties["MYVERSION"];
pProperty.set_Value(ref "3.3.1.456.0");
pProject.SaveProject();
}
}
Errors;
Error 1 The type 'ISWiAuto12.ISWiPropertyClass' has no constructors defined C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 15 49 iswiproperty
Error 2 A ref or out argument must be an assignable variable C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 18 37 iswiproperty
Error 3 The best overloaded method match for 'ISWiAuto12._ISWiProperty.set_Value(ref string)' has some invalid arguments C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 18 13 iswiproperty
Error 4 Argument '1' must be passed with the 'ref' keyword C:\temp\iswiproperty\iswiproperty\iswiproperty\Program.cs 18 37 iswiproperty
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
10:46 AM
This seems to work as a hasty mock-up in InstallShield 2009 (assuming the property MYVERSION already exists in the Property table):[code]using System;
using System.Collections.Generic;
using System.Text;
namespace ISWiAuto15CS
{
class Program
{
static void Main(string[] args)
{
ISWiAuto15.ISWiProject ism = new ISWiAuto15.ISWiProject( );
ism.OpenProject(@"C:\InstallShield 2009 Projects\BasicMsi2009.ism",
false);
ISWiAuto15.ISWiProperty pProperty = ism.ISWiProperties["MYVERSION"];
String myVersion = "3.3.1.456.0";
pProperty.set_Value(ref myVersion);
ism.SaveProject( );
ism.CloseProject( );
}
}
}[/code]
using System.Collections.Generic;
using System.Text;
namespace ISWiAuto15CS
{
class Program
{
static void Main(string[] args)
{
ISWiAuto15.ISWiProject ism = new ISWiAuto15.ISWiProject( );
ism.OpenProject(@"C:\InstallShield 2009 Projects\BasicMsi2009.ism",
false);
ISWiAuto15.ISWiProperty pProperty = ism.ISWiProperties["MYVERSION"];
String myVersion = "3.3.1.456.0";
pProperty.set_Value(ref myVersion);
ism.SaveProject( );
ism.CloseProject( );
}
}
}[/code]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 11, 2008
11:19 AM
That works in IS 12 also.
Thanks
Since I have IS 12 and IS2008 on the same machine I think I'm going to try the regex first.
Thanks
Since I have IS 12 and IS2008 on the same machine I think I'm going to try the regex first.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 10, 2009
08:21 AM
L'exception System.IndexOutOfRangeException n'a pas été gérée
HelpLink="#1000005"
Message="Item not found\r\n > ISWiAutomation.ISWiProperties.Item"
Source="ISWiAuto12"
StackTrace:
à ISWiAuto12.ISWIPropertiesClass.get_Item(Object vntIndexKey)
à GenProduct.Program.Main(String[] args) dans C:\Documents and Settings\jerome\Bureau\GenProduct\Program.cs:ligne 176
à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
HelpLink="#1000005"
Message="Item not found\r\n > ISWiAutomation.ISWiProperties.Item"
Source="ISWiAuto12"
StackTrace:
à ISWiAuto12.ISWIPropertiesClass.get_Item(Object vntIndexKey)
à GenProduct.Program.Main(String[] args) dans C:\Documents and Settings\jerome\Bureau\GenProduct\Program.cs:ligne 176
à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Apr 16, 2009
05:12 AM
profil92 wrote:
L'exception System.IndexOutOfRangeException n'a pas été gérée
HelpLink="#1000005"
Message="Item not found\r\n > ISWiAutomation.ISWiProperties.Item"
Source="ISWiAuto12"
StackTrace:
à ISWiAuto12.ISWIPropertiesClass.get_Item(Object vntIndexKey)
à GenProduct.Program.Main(String[] args) dans C:\Documents and Settings\jerome\Bureau\GenProduct\Program.cs:ligne 176
à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
RobertDickau wrote:
This seems to work as a hasty mock-up in InstallShield 2009 (assuming the property MYVERSION already exists in the Property table):[code]using System;
using System.Collections.Generic;
using System.Text;
namespace ISWiAuto15CS
{
class Program
{
static void Main(string[] args)
{
ISWiAuto15.ISWiProject ism = new ISWiAuto15.ISWiProject( );
ism.OpenProject(@"C:\InstallShield 2009 Projects\BasicMsi2009.ism",
false);
ISWiAuto15.ISWiProperty pProperty = ism.ISWiProperties["MYVERSION"];
String myVersion = "3.3.1.456.0";
pProperty.set_Value(ref myVersion);
ism.SaveProject( );
ism.CloseProject( );
}
}
}[/code]
[FONT="Tahoma"]
i've an execption, but why ? if you have a solution for me it's excellent because the CHM Help in installshield 12 premier isn't a good reference for help me.
in fact i would like to realise a C# program who automatise some opperation
like copy files and folders, generate a build/release with installshield automation, i've create before the setup type and version of product manually.
in my program for installshield, i used the name of product already created the exit for this part is générate the new setup.exe whith the same installscript but the new installfiles.
detail of the error message :
L'exception System.IndexOutOfRangeException n'a pas été gérée
HelpLink="#1000005"
Message="Item not found\r\n > ISWiAutomation.ISWiProperties.Item"
Source="ISWiAuto12"
StackTrace:
à ISWiAuto12.ISWIPropertiesClass.get_Item(Object vntIndexKey)
à GenProduct.Program.Main(String[] args) dans C:\Documents and Settings\jerome\Bureau\GenProduct\Program.cs:ligne 176
à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()[/FONT]