gluck/il-repack

Failed to find target platform 'v4'

Closed this issue · 6 comments

I am trying to change a .NET 2 exe to .NET 4, but getting the error below. Works with ILMerge.

Seems there is a TargetPlatformDirectory option, but not exposed.

System.ArgumentException: Failed to find target platform 'v4' in 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App'
   at ILRepacking.ILRepack.ResolveTargetPlatformDirectory(String version) in /_/ILRepack/ILRepack.cs:line 244
   at ILRepacking.ILRepack.ResolveSearchDirectories() in /_/ILRepack/ILRepack.cs:line 608
   at ILRepacking.ILRepack.RepackCore(String tempOutputDirectory) in /_/ILRepack/ILRepack.cs:line 333
   at ILRepacking.ILRepack.Repack() in /_/ILRepack/ILRepack.cs:line 295
   at ILRepacking.Application.Main(String[] args) in /_/ILRepack/Application.cs:line 49

any chance you could include a zip with the repro and a cmd file that has the exact command line that you use?

Here you go. I have also include the possible locations where .NET Framework stuff lives on my PC.

ilrepack-371.zip

Hmm when I try this, it works fine.

I'm running the desktop, 64-bit version of ILRepack.exe (the one we ship).
typeof(string).Assembly.Location resolves to C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll

image

Could you be running the .NET Core version? The .NET Core version is primary for cross-plat support and I don't think it will properly support desktop framework.

Could you be running the .NET Core version? The .NET Core version is primary for cross-plat support and I don't think it will properly support desktop framework.

Yes, I am running the dotnet tool.

And it is unfortunate, because I am specifically working on cross-platform build/packaging support.

Will find some other solution.

Have you tried passing the targetplatform?

var targetPlatform = cmd.Option("targetplatform");

maybe if you pass both the desktop directory and v4 it will work then?

Yes, I tried a few things.

In the end, I only needed to indicate the .NETFramework runtime.

Just wrote something quick in cecil (that works for my use case).

https://github.com/IronScheme/IronScheme.BuildTools/blob/master/RuntimeChanger/RuntimeChanger.cs