Error while Building (compile) wixproj using MSBuild api 15.9.20 - msbuild

I'm using wix in a project and i have a specific need :
Build wixproj using MSBuild from c#.
For that i'm using MSBuild api as folowing :
static void Main(string[] args)
{
string toolsPath = ToolLocationHelper.GetPathToBuildToolsFile("msbuild.exe", ToolLocationHelper.CurrentToolsVersion);
ProjectCollection projectCollection = new ProjectCollection();
projectCollection.AddToolset(new Toolset(ToolLocationHelper.CurrentToolsVersion, Path.GetDirectoryName(toolsPath), projectCollection, string.Empty));
Project project = projectCollection.LoadProject("TestWix.wixproj");
var result = project.Build(new ConsoleLogger());
Console.ReadKey();
}
And i get this error :
C:\Program Files (x86)\MSBuild\Microsoft\WiX\v3.x\wix2010.targets(1988,5): error MSB4127: The "GenerateCompileWithObjectPath" task could not be instantiated from the assembly "C:\Program Files (x86)\WiX Toolset v3.11\bin\WixTasks.dll". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Tools.WindowsInstallerXml.Build.Tasks.GenerateCompileWithObjectPath' to type 'Microsoft.Build.Framework.ITask'.
But when i use msbuild command line it's work fine.
Do you have any idea please ?
Thank you in advance.

Related

Setting up pythonnet for .net using NuGet

Iam trying to develop a simple calculator program embeddeding python in .net,I wanna reference pythonnet from NuGet to include it in my project
I installed pythonnet v2.3.0 using NuGet,I also have python 3 installed in my system
It would be nice if some one give me step by step instruction to embedd python net
form1.cs code :
using System;
...
using Python.Runtime;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
PythonEngine.Initialize();
}
private void button1_Click(object sender, EventArgs e)
{
int num1 = int.Parse(a.Text);
int num2 = int.Parse(b.Text);
result.Text = (num1 + num2).ToString();
using (Py.GIL())
{
dynamic np = Py.Import("numpy");
}
}
}
}
When I use using(Py.GIL()) line in my code it compiler shows
System.BadImageFormatException: 'Could not load file or assembly
'Python.Runtime, Version=2.3.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. An attempt was made
to load a program with an incorrect format.'
This issue is likely caused by architecture (32-bit/64-bit) mismatch between Python.Runtime.dll and your Python.
pythonnet 2.3.0 NuGet packages currently published on nuget.org include two versions of the Python.Runtime.dll assembly: 32-bit(x86) and 64-bit(x64). There is a known issue with this package not installing the correct reference in the project, even if the project platform is set to 64-bit:
https://github.com/pythonnet/pythonnet/issues/472.
Usually the x86 reference gets installed, and if your Python is 64-bit, you get the above exception.
To fix this:
Remove the existing assembly reference from the project.
Manually add reference to the correct assembly from the installed nuget package (e.g. your_solution_dir\packages\pythonnet_py35_dotnet.2.3.0\lib\net40\x64\Python.Runtime.dll)
Changed the CPU architecture from AnyCPU to x64 and it fixed the issue.
I had same problem. I was running KerasExampleWinApp Sample (keras.net). The error was:
"...Python.Runtime, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies..."
To solve it, I just deleted the Nugget Reference and reinstalled it.

The type 'Application' is defined in an assembly that is not referenced. gtk-sharp, Version=2.12

I am building an application using GTK# 2.12 version. I installed MonoDevelop for that. Made a sample application.
When I changed the setting from GTK#3 to GTK# 2.12 on the project then all references are updated to GTK#2.12.
When I am compiling the project then compiler throws an error.
/local/mnt/workspace/vkumbhan/work/Program.cs(25,25): Error CS0012: The type 'Application' is defined in an assembly that is not referenced. You must add a reference to assembly 'gio-sharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f'. (CS0012)
class MainClass
{
public static void Main(string[] args)
{
Application.Init(); //error came this line
MainWindow win = new MainWindow();
win.Show();
Application.Run(); //error came this line
}
}
When I looked at the references for the Application class then I found it the Application refer to gtk-sharp 3.0.0.0.
For checking GTK# 2.12 installed or not.
apt-cache policy libgtk2.0-0 libgtk-3-0
both versions are installed on the machine.
Could you please help me, how to resolve the issue?
Find the command line: Please help to update references 2.12.0.0 instead of 3.0.0.0
/usr/lib/mono/msbuild/15.0/bin/Roslyn/csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:/usr/lib/mono/gac/atk-sharp/3.0.0.0__35e10195dab3c99f/atk-sharp.dll /reference:/usr/lib/mono/gac/gdk-sharp/3.0.0.0__35e10195dab3c99f/gdk-sharp.dll /reference:/usr/lib/mono/gac/glade-sharp/2.12.0.0__35e10195dab3c99f/glade-sharp.dll /reference:/usr/lib/mono/gac/gtk-sharp/3.0.0.0__35e10195dab3c99f/gtk-sharp.dll /reference:/usr/lib/mono/4.5-api/Mono.Posix.dll /reference:/usr/lib/mono/4.5-api/mscorlib.dll /reference:/usr/lib/mono/gac/pango-sharp/3.0.0.0__35e10195dab3c99f/pango-sharp.dll /reference:/usr/lib/mono/4.5-api/System.Core.dll /reference:/usr/lib/mono/4.5-api/System.dll /debug+ /debug:portable /optimize- /out:obj/Debug/Sample.exe /subsystemversion:6.00 /resource:gtk-gui/gui.stetic,gui.stetic /target:winexe /utf8output MainWindow.cs Program.cs Properties/AssemblyInfo.cs gtk-gui/generated.cs gtk-gui/MainWindow.cs "/tmp/.NETFramework,Version=v4.5.AssemblyAttributes.cs"
Thanks!
The easiest way to solve this is to create a new Gtk# app in MonoDevelop, which defaults to Gtk# 2.12, since the designer needs that version.
Then you can copy the class files (*.cs) from the project that does not compile.

Wix light.exe : error LGHT0001: The system cannot open the device or file specified.

Today we build our product with MSBuild /m to build with multiprocess.
Before we do a change to heat some files in pre-build event, build with MSBuild multiprocess can be success.
Now build is failed with following exception:
124>light.exe : error LGHT0001: The system cannot open the device or file specified. (Exception from HRESULT: 0x8007006E) [...MSI.wixproj]
Exception Type: System.IO.FileLoadException
Stack Trace:
at Microsoft.Tools.WindowsInstallerXml.MergeMod.IMsmMerge2.OpenModule(String fileName, Int16 language)
at Microsoft.Tools.WindowsInstallerXml.Binder.MergeModules(String tempDatabaseFile, Output output, FileRowCollection fileRows, StringCollection suppressedTableNames)
at Microsoft.Tools.WindowsInstallerXml.Binder.BindDatabase(Output output, String databaseFile)
at Microsoft.Tools.WindowsInstallerXml.Binder.Bind(Output output, String file)
at Microsoft.Tools.WindowsInstallerXml.Tools.Light.Run(String[] args)
(Link target) ->
light.exe : error LGHT0001: The system cannot open the device or file specified. (Exception from HRESULT: 0x8007006E) [...Msi.wixproj]
using Wix 3.8
After investigation with team, we find out root cause.
ProductMSI.sln has more than 50 MSI wix projects and all shared MSM projects to build.
Each MSI project has a post build event action that it will reopen MSI related MSM to do some change to MSI by WindowsInstaller API as DataBase. And it opens MSM as read&edit mode by API.
So if one shared MSM is opened by one MSI post event and will be opened by another wix project to compile. Open request will be denied. The above error will be thrown.
Solution:
1.Change post event action to open MSM as read-only, instead of read&edit mode.
We test it pass.

Strange error while attempting to use Zip task from .net 4.0 version of MSBuild.ExtensionPack

We've been getting inconsistent results from the Zip task in Tigris MSBuild task library, so we're trying to use the Zip task in the MSBuild.ExtensionPack for .NET 4.0. But when we execute this new Zip task, we get the following error from the MSBuild executable:
C:\development\build\PrepareLastKnownGood.csproj(40,3): error : Typ
eInitializationException: The type initializer for 'java.lang.System' threw an
exception.\r
C:\development\build\PrepareLastKnownGood.csproj(40,3): error : Unsat
isfiedLinkError: Unable to load DLL 'vjsnativ': The specified module could not
be found. (Exception from HRESULT: 0x8007007E)\r
Has anyone else encountered this error in their use of the Zip task from MSBuild.ExtensionPack? If so, how did you resolve it?
Zip task from MSBuild.ExtensionPack.JSharp.dll is implemented in J#. And has dependency to the vjslib.dll.
You need to install Microsoft Visual J# Version 2.0 Redistributable Package.

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException

I have the following code set up in my Startup
IDictionary<string, string> properties = new Dictionary<string, string>();
properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect");
properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle");
properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
properties.Add("connection.connection_string", "Data Source=ZEUS;Initial Catalog=mydb;Persist Security Info=True;User ID=sa;Password=xxxxxxxx");
InPlaceConfigurationSource source = new InPlaceConfigurationSource();
source.Add(typeof(ActiveRecordBase), (IDictionary<string, string>) properties);
Assembly asm = Assembly.Load("Repository");
Castle.ActiveRecord.ActiveRecordStarter.Initialize(asm, source);
I am getting the following error:
failed: NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException : Unable to load type 'NNHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Possible causes are:
The NHibernate.Bytecode provider assembly was not deployed.
The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.
I have read and read I am referecning the All the assemblies listed and I am at a total loss as what to try next.
Castle.ActiveRecord.dll
Castle.DynamicProxy2.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
NHibernate.ByteCode.Castle.dll
Castle.Core.dll.
I am 100% sure the assembly is in the bin. Anyone have any ideas?
This problem occurs when NHibernate.ByteCode.Castle.dll was built with a different target platform as your project. To test this, change your program target platform from one or more of the following:
x64 to x86
x86 to x64
"Any CPU" to x86
"Any CPU" to x64
If any of those solve your problem, then you know that you just need to synchronize the DLL and your target platform.
I had this problem also, my solution was to add in the Assembly that creates session following code.
private NHibernate.ByteCode.Castle.ProxyFactoryFactory requiredButNeverUsed;