How to get IKVM to build in Visual Studio 2008? - c#

I've downloaded the IKVM sources (http://www.ikvm.net/) from http://sourceforge.net/cvs/?group_id=69637
Now I'm trying to get it to build in Visual Studio 2008 and am stuck. Does anyone know of documentation of how to build the thing, or could even give me pointers?
I've tried opening the ikvm8.sln, which opens all the projects, but trying to build the solution leads to a bunch of "type or namespace could not be found" errors.
As you can probably guess I'm no Visual Studio expert, but rather am used to working with Java in Eclipse.
So again, I'm looking for either: step-by-step instructions or a link to documentation on how to build IKVM in Visual Studio.
Let me know if you need any more info. Thanks for any help!
Edit: I've also tried a manual "MsBuild.exe IKVM8.sln", but also get a bunch of:
JniInterface.cs(30,12): error CS0234: The type or namespace name 'Internal' does not exist in the namespace 'IKVM' (a
re you missing an assembly reference?)
JniInterface.cs(175,38): error CS0246: The type or namespace name 'ClassLoaderWrapper' could not be found (are you mi
ssing a using directive or an assembly reference?)
JniInterface.cs(175,13): error CS0246: The type or namespace name 'ClassLoaderWrapper' could not be found (are you mi
ssing a using directive or an assembly reference?)
Edit #2: I noticed a "ikvm.build" file so I downloaded and ran nant on the folder, which got me a step further. A few things start to build successfully, unfortunately I now get the following error:
ikvm-native-win32:
[mkdir] Creating directory 'C:\Documents and Settings\...\My Documents\ikvm\ikvm\native\Release'.
[cl] Compiling 2 files to 'C:\Documents and Settings\...\My Documents\ikvm\ikvm\native\Release'.
BUILD FAILED
C:\Documents and Settings\...\My Documents\ikvm\ikvm\native\native.build(17,10):
'cl' failed to start.
The system cannot find the file specified
Total time: 0.2 seconds.
Edit #3: OK solved that by putting cl.exe in the path, still getting other errors though. Note this is all for building it on the console e.g. with Nant. Is there no way to get it to build in Visual Studio? That would be sad...
Edit #4: Next step was installing GNU classpath 0.95, and now it looks like I need a specific OpenJDK installation... Linux AMD64?!
[exec] javac: file not found: ..\..\openjdk6-b12\control\build\linux-amd64\gensrc\com\sun\accessibility\internal\resources\accessibility.java
[exec] Usage: javac <options> <source files>
[exec] use -help for a list of possible options
Edit #5: Got an answer from the author. See below or at http://weblog.ikvm.net/CommentView.aspx?guid=7e91b51d-6f84-4485-b61f-ea9e068a5fcf Let's see if it works...
Edit #6 As I feared, next problem: "cannot open windows.h", see separate question here.
Final Edit: Found Solution! After getting the Platform SDK folders in the Lib and Path environment variables, the solution I described below worked for me.

I don't know that this would do it for you but can you try building from the command line?
msbuild ________
I think that's how I built the application due to the same issues.

OK just got the following reply from the author: http://weblog.ikvm.net/CommentView.aspx?guid=7e91b51d-6f84-4485-b61f-ea9e068a5fcf
If you want to build from cvs, you're on your own. However, you can more easily build from source if you use an official release.
If you download ikvm-0.36.0.11.zip, classpath-0.95-stripped.zip and openjdk-b13-stripped.zip from SourceForge (the last two are under the ikvm 0.36.0.5 release) you have all the sources that are needed.
Now you'll have to open a Visual Studio 2008 Command Prompt (i.e. one that has cl.exe and peverify in the path).
Then in the ikvm root directory, do a "nant clean" followed by "nant". That should build the whole project. After you done that, you should be able to build in Visual Studio (debug target only), but you may need to repair the assembly references in the projects (unless you have ikvm installed in c:\ikvm).
Regards,
Jeroen
Edit: After making sure the Platform SDK folders were in the Path and Lib environment variables, this worked for me. Thanks, Jeroen!

This is how I built IKVM 8.1.5717.0 from source. Visual Studio is not required.
Create a folder:
c:\ikvm\
Add the above folder to PATH (e.g. set PATH=%PATH%;c:\ikvm and leave command prompt open for later).
Download:
ikvmsrc-8.1.5717.0.zip (http://www.frijters.net/ikvmsrc-8.1.5717.0.zip)
Unzip and place "ikvm-8.1.5717.0" folder in c:\ikvm\
Download:
openjdk-8u45-b14-stripped.zip (http://www.frijters.net/openjdk-8u45-b14-stripped.zip)
Unzip and place "openjdk-8u45-b14" folder in c:\ikvm\
Download:
Java 8 SDK (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
Install and make sure location is added to path
Download:
NAnt 0.92 (https://sourceforge.net/projects/nant/files/nant/0.92/nant-0.92-bin.zip/download)
Unzip and place "nant-0.92" folder in c:\ikvm\
ICSharpCode.SharpZipLib.dll (http://www.icsharpcode.net/opensource/sharpziplib/Download.aspx)
Place "ICSharpCode.SharpZipLib.dll" in C:\ikvm\ikvm-8.1.5717.0\bin\
Open the following file in a text editor and change the version number:
C:\ikvm\ikvm-8.1.5717.0\CommonAssemblyInfo.cs.in
Using command prompt from earlier, cd to:
C:\ikvm\ikvm-8.1.5717.0\ikvm\
Run:
..\nant-0.92\bin\NAnt.exe
If successful all the binaries will be in:
C:\ikvm\ikvm-8.1.5717.0\bin

Related

TeamCity C# build failed most likely because of nuget restore issue

I am trying to set up a new TeamCity build job and am facing a build issue.
The build failed because of missing references within ResolveProjectReferences step.
For instance :
JSonTools\JSonHelper.cs(21, 7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
Prior to the build step, 2 restore nuget steps are set up and both ran successfully (one for sdk like project and the second for previous version, in this order)
When I run my solution on the agent and restore nuget packages through VS it is working fine (and TC job will run successfully if made on the same agent)
I noticed the dlls pulled during the restore nuget steps are in the path of my sln, while it seems to be require on others path.
Several VCS are set for this job and from what i can see/understand, the failing projects seem to require the dll to be in their own path under the packages folder.
\this
\is
\my
\path
Project1.csproj
packages\ (<- contains all the Dlls)
\folder1
\Project2.csproj
\Project3.csproj
\packages\ (I have the feeling some Dlls should be here but the folder doesn't exist)
\folder2
\Project4.csproj
\packages\ (same as previously)
Did I missed something ?
Any help would be appreciated.
Thanks,
Cervelle

Build a WPF application in VScode gave me error MSB4062

I am trying to perform a build on a WPF (.Net Core 3.1) in Visual Studio Code (not Visual Studio this time cause I need a more lightweight editor).Normally all my project can be built fine, but this WPF project gave me this following error:
C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.
WinFX.targets(225,9): error MSB4062: The "Microsoft.Build.Tasks.Windows.MarkupCompilePass1" task could not be loaded from
the assembly C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\netcoreapp2.1\PresentationBuildTasks.dll. Could not load file or assembly 'C:\Program Files
%28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\netcoreapp2.1\PresentationBuildTasks.dll'. The system cannot find the path specified.
Confirm that the <UsingTask> declaration is correct, that the assembly and all
its dependencies are available, and that the task contains a public class that
implements Microsoft.Build.Framework.ITask. [E:\ui_wpf_test\ui_wpf_test.csproj]
The build failed. Fix the build errors and run again.
I heard that it has to do with MSbuild, but I dont know how to correctly fix this
I found a solution on GitHub. You have to replace the following line of %ProgramFiles(x86)%\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFx.props:
<_PresentationBuildTasksAssembly Condition="'$(_PresentationBuildTasksAssembly)'==''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\tools\$(_PresentationBuildTasksTfm)\PresentationBuildTasks.dll'))</_PresentationBuildTasksAssembly>
Replace it with:
<_PresentationBuildTasksAssembly Condition="'$(_PresentationBuildTasksAssembly)'==''">$(MSBuildThisFileDirectory)..\tools\$(_PresentationBuildTasksTfm)\PresentationBuildTasks.dll</_PresentationBuildTasksAssembly>
This has eventually worked for me.
small bug. should be fixed in the new upcoming 3.1.103 instead of now 3.1.102.
Problem is the path Program Files (x86)' where(x86)is escaped to%28x86%29`, resulting in path not found.
temporary fix by just escaping the path:
Go to:
C:\Program Files (x86)\dotnet\sdk\3.1.102\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets
edit Microsoft.WinFx.props and use this _PresentationBuildTaskAssembly which has the Unescape for the path:
<_PresentationBuildTasksAssembly Condition="'$(_PresentationBuildTasksAssembly)'==''">$([MSBuild]::Unescape($([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\tools\$(_PresentationBuildTasksTfm)\PresentationBuildTasks.dll'))))</_PresentationBuildTasksAssembly>
It is possible that you can resolve it also by changing in visual studio the build to x64 instead of Any CPU/x86. With 64-bit this will use C:\Program Files\ instead of C:\Program Files (x86)\ and thus not have the 'bad' characters.

How to embed or-tools in a C# application?

I'm trying to follow the instructions at https://developers.google.com/optimization/introduction/installing.html#windows_binary so that I can use or-tools inside my C# application.
I'm stuck on the make all step. I am in the Developer Command Prompt, but this command says:
'make' is not recognized as an internal or external command,
operable program or batch file.
I tried downloading GNU make, but that fails also. make install says "no target", and a bare make says:
process_begin: CreateProcess(NULL, cl /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo /O2 -DNDEBUG -DUSE_CBC -DUSE_CLP /D__WIN32__ /Iinclude\src\windows /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /Iinclude /Iexamples -DUSE_GLOP -DUSE_BOP -c examples\cpp\costas_array.cc /Foobjs\costas_array.obj, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [objs\\costas_array.obj] Error 2
I also tried copying the DLLs from the bin folder directly into my project. I was able to compile against them by doing this, but when I tried to run it I got an error:
System.BadImageFormatException: 'Could not load file or assembly 'Google.OrTools, Version=5.1.6235.37215, Culture=neutral, PublicKeyToken=7a052e3db761d3be' or one of its dependencies. An attempt was made to load a program with an incorrect format.'
What am I missing?
Regarding the System.BadImageFormatException:
The OrTools binary format is provided in a 64bit dll.
Make sure, that your project is set to 64bit:
In Visual Studio you can check it out by right clicking on the Project --> Properties --> Build, Platform Target: This should be set to x64.
In case you have the same issue with web application, just enable 64 bits on IIS Express using Tools -> Options -> Projects and Solutions -> Web Projects -> Use the 64-bit version on IIS Express for web sites and projects
I was having this issue when using OR-Tools in a Web Application (it worked fine in a console application). I was getting:
System.BadImageFormatException HResult=0x8007000B Message=Could not load file or assembly 'Google.OrTools' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Using x64 didn't help, and Octopus was not building the project correctly either. The solution that worked for me was specifying which ASPNETCOMPILER to use (x64) in the project's .csproj :
<Project .... >
<PropertyGroup>
<AspNetToolPath>$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspNetToolPath>
</PropertyGroup>

Compile a C# visual studio console application in mono (mac)

I am pretty new to mono and C# so this is probably a simple question, but i cannot find the answer.
I need to compile a C# visual studio console application on my mac. I thought mono would be right for that purpose. I don't know which file to compile and took program.cs (where my main function is) or should i compile Project.csproj.
When i run
gmcs Program.cs
I get
Program.cs(17,16): error CS0246: The type or namespace name `Oplossing' could not be found. Are you missing an assembly reference?
Program.cs(129,54): error CS0246: The type or namespace name `Order' could not be found. Are you missing an assembly reference?
What en how should i compile?
Via xbuild, you should be able to compile csproj directly,
http://www.mono-project.com/Microsoft.Build
Unless you are working on a system without a ui, (since you are targetting macos you have a ui) download and install Monodevelop and open the visual studio project with that.
Otherwise check the (g) mcs documentation
The way to use it is already in te comments here
Note: you do NOT have to recompile your app on MacOs to run it on MacOS, just copy the exe (assembly) to your mac and execute it with mono

WebDeploy API for .NET

I've installed MSDeploy on my machine. I am using Visual Studio 2010 and C#. Trying to load 'Microsoft.Web.*' to code some sexy msdeploy functionality. Perhaps I'm a level 3 tard (highly probable) but the documentation for getting this absolutely blow as#.
The error I get is:
"The type or namespace name 'Web' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"
So -- of course I try to load it via References, but it aint there. I then Google like a mf for "webdeploy api C#" and the such and cannot for the love of the giant spaghetti monster find anything on how to install / download the msdeploy ("microsoft.web.*) .dlls, apis.
Anyone can point a brother to a link?
I did download and install "WebDeploymentSetup.msi", but nope. I did install "webdeploy_en.msi" but nope. Then I found this craaaazy thing called "AzurePack.exe" -- didn't even try to install that. But, will if someone says that's it.
Thanks.
The Microsoft.Web.Deployment.dll can be found here:
c:\Program Files\IIS\Microsoft Web Deploy V3\Microsoft.Web.Deployment.dll
Point a reference to that.
The only prerequisite is installing WebDeploy v3.0:
http://www.iis.net/downloads/microsoft/web-deploy

Categories