Select .net Runtime for build msi

Jun 2, 2015 at 3:02 PM
I create msi packege with one Custom Action and when I run this package on Windows 7 with .net framework 3.5 I recive error.

System.BadImageFormatException: Could not load file or assembly 'project.wix' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

If I use cscs.exe /version:v3.5 Project.cs for build, it's dont help.

How I can set installer runtime to 3.5?
Jun 3, 2015 at 6:49 AM
Normally you control this via app.config CustomAction.config. This file is automatically generated and should satisfy all runtimes..but to ensure that it is the case you may want to run your build script as a v3.5 assembly. For that you need to build your assembly with VS+target in settings or run cscs.exe v3.5 (note switch /version doesn't exist).

You can grab cscs.exe v3.5 from here: https://csscriptsource.codeplex.com/releases/view/614904

You will find it inside of the archive file at this location: <cs-script>\lib\Bin\NET 3.5\cscs.exe
Jun 3, 2015 at 9:18 AM
Edited Jun 3, 2015 at 9:18 AM
& 'D:\Build\Tools\cs-script\lib\Bin\NET 4.5\cscs.exe' .\Src\project.cs
Build project normaly but

& 'D:\Build\Tools\cs-script\lib\Bin\NET 3.5\cscs.exe' .\Src\project.cs

Error: Specified file could not be compiled.

csscript.CompilerException:
..\trunk\Src\project.cs(53,3): error CS1501: Ни одна из перегрузок метода 'ResolveWildCards' не принимает '0' аргумент(ов)
..\trunk\Src\project.cs(79,47): error CS1729: "WixSharp.ShowDialog" не содержит конструктор, который принимает аргументы "1"
..\trunk\Src\project.cs(80,50): error CS1729: "WixSharp.ShowDialog" не содержит конструктор, который принимает аргументы "1"

в csscript.CSExecutor.ProcessCompilingResult(CompilerResults results, CompilerParameters compilerParams, ScriptParser
parser, String scriptFileName, String assemblyFileName, String[] additionalDependencies)
в csscript.CSExecutor.Compile(String scriptFileName)
в csscript.CSExecutor.ExecuteImpl()
Jun 3, 2015 at 10:19 AM
Edited Jun 3, 2015 at 10:21 AM
Resolved

Change
project.ResolveWildCards(); 
to
project.ResolveWildCards(false);
and
project.CustomUI = new DialogSequence()
           .On(Dialogs.WelcomeDlg, Buttons.Next, new ShowDialog(Dialogs.InstallDirDlg))
           .On(Dialogs.InstallDirDlg, Buttons.Back, new ShowDialog(Dialogs.WelcomeDlg));
to
project.CustomUI = new DialogSequence()
          .On(Dialogs.WelcomeDlg, Buttons.Next, new ShowDialog(Dialogs.InstallDirDlg, Condition.Always))
          .On(Dialogs.InstallDirDlg, Buttons.Back, new ShowDialog(Dialogs.WelcomeDlg, Condition.Always));
After that project.cs.dll (dll with custom actions) builded for Runtime Version v2.0.50727

As I understand, if I use cscs.exe for .net 3.5
Counstructors don't understand default values like
public WixSharp.Project ResolveWildCards([bool ignoreEmptyDirectories = false])

Thanks for help
Jun 3, 2015 at 12:01 PM
It makes sense. Default arguments were introduced in .NET v4.0 and under older CLR it falls back to the signature with explicit arguments.