Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Specified method is not supported" on net5.0 #273

Closed
aalmada opened this issue Jul 31, 2020 · 12 comments
Closed

"Specified method is not supported" on net5.0 #273

aalmada opened this issue Jul 31, 2020 · 12 comments

Comments

@aalmada
Copy link

aalmada commented Jul 31, 2020

I'm using ILRepack.MSBuild.Task 2.0.1 on .NET 5.0.100-preview.7 with target framework netstandard2.0.

I'm getting the following error when I run dotnet build on the command line:

C:\Projects\NetFabric.Hyperlinq\NetFabric.Hyperlinq.SourceGenerator\NetFabric.Hyperlinq.SourceGenerator.csproj(31,5): error : Specified method is not supported.
C:\Projects\NetFabric.Hyperlinq\NetFabric.Hyperlinq.SourceGenerator\NetFabric.Hyperlinq.SourceGenerator.csproj(31,5): error :    at Mono.Cecil.ModuleParameters.GetCurrentRuntime()
C:\Projects\NetFabric.Hyperlinq\NetFabric.Hyperlinq.SourceGenerator\NetFabric.Hyperlinq.SourceGenerator.csproj(31,5): error :    at Mono.Cecil.ModuleParameters..ctor()
C:\Projects\NetFabric.Hyperlinq\NetFabric.Hyperlinq.SourceGenerator\NetFabric.Hyperlinq.SourceGenerator.csproj(31,5): error :    at ILRepacking.ILRepack.Repack()
C:\Projects\NetFabric.Hyperlinq\NetFabric.Hyperlinq.SourceGenerator\NetFabric.Hyperlinq.SourceGenerator.csproj(31,5): error :    at ILRepack.MSBuild.Task.ILRepack.Execute()

I don't get the error when I build inside Visual Studio.

I reported the issue on Cecil (jbevain/cecil#669) but it seems the issue is with ILRepack.

@sanikolov
Copy link

+1
agreed, getting the same on .net 5.0.

@lextm
Copy link

lextm commented Oct 28, 2020

Related to #236

TheAngryByrd added a commit to TheAngryByrd/pulsar-mods that referenced this issue Jan 31, 2021
@replaysMike
Copy link

bump, I believe this is fixed in Cecil now. Would be great to have an update for this as it's blocking .net 5 support for several of my packages.

@replaysMike
Copy link

actually, I rolled back my .Net 5 support and am still seeing the error in ILRepack 2.0.13.
<TargetFrameworks>netstandard2.0;net48</TargetFrameworks>

error : Specified method is not supported.
error :    at Mono.Cecil.ModuleParameters.GetCurrentRuntime()
error :    at Mono.Cecil.ModuleParameters..ctor()
error :    at ILRepacking.ILRepack.Repack()
error :    at ILRepack.MSBuild.Task.ILRepack.Execute()

ErisApps added a commit to ErisApps/CatCore that referenced this issue Mar 22, 2021
This saddens me...
ILRepack is using an old version of Cecil, which throws an exception when being used on .NET 5
gluck/il-repack#236
gluck/il-repack#273

It's supposedly fixed in the up-to-date versions of Cecil though
jbevain/cecil#669

On the other hand... it's already fixed in a fork of ILRepack (but that one got archieved 16 days ago and no new nuget package has been made available 😭)
peters/il-repack#2
ErisApps added a commit to ErisApps/CatCore that referenced this issue Mar 24, 2021
This saddens me...
ILRepack is using an old version of Cecil, which throws an exception when being used on .NET 5
gluck/il-repack#236
gluck/il-repack#273

It's supposedly fixed in the up-to-date versions of Cecil though
jbevain/cecil#669

On the other hand... it's already fixed in a fork of ILRepack (but that one got archieved 16 days ago and no new nuget package has been made available 😭)
peters/il-repack#2
@triforcely
Copy link

Is there any progress on this issue?

@andrei-epure-sonarsource

Is there any update?

@sanikolov
Copy link

sanikolov commented Mar 30, 2022

I recommend the following alternative:

add this to your csproj

<PackageReference Include="ILMerge.Fody" Version="1.22.0" PrivateAssets="All" />

and then place lines like the following in the folder where the csproj lives (the filename must be FodyWeavers.xml)

<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
      <ILMerge IncludeAssemblies='foo.bar.*|Newtonsoft.Json.*|etc' />
</Weavers>

This worked for me on .NET Core all the way to 6.0 and probably beyond.
I haven't tested it on any netfx version.
The best part is that it allows multiple DLLs to be merged into a single DLL which the coreclr single deployment tools do NOT allow (which is ridiculous).

@calwi
Copy link

calwi commented Nov 8, 2022

Any chance this can work in .net 6.0? Works fine locally in VS 2022, but get this error in Azure Devops.

vmimage: windows-latest

@chejunkie
Copy link

chejunkie commented Apr 16, 2023

I have the exact same issue as @aalmada ILRepack 2.0.18 in .net6. I tried @sanikolov proposed workaround but it did not work for me.

Edit: I should also mention to be clearer, that building from VS2022 succeeds and I can see the two name spaces when opening the combined DLL in a decompiler (e.g., dotPeek), but VS cannot pickup the methods in the combined DLL. I then attempted to dotnet build the project, which is when I got the same errors:

Build FAILED.
.csproj(31,5): error : Specified method is not supported.
.csproj(31,5): error : at Mono.Cecil.ModuleParameters.GetCurrentRuntime()
.csproj(31,5): error : at Mono.Cecil.ModuleParameters..ctor()
.csproj(31,5): error : at ILRepacking.ILRepack.Repack()
.csproj(31,5): error : at ILRepack.MSBuild.Task.ILRepack.Execute()
0 Warning(s)
1 Error(s)

Line 31 from the project file shows ILRepack is not understood?

<ILRepack OutputType="$(OutputType)" MainAssembly="$(AssemblyName).dll" OutputAssembly="$(AssemblyName).dll" InputAssemblies="@(InputAssemblies)" InternalizeExcludeAssemblies="@(InternalizeExcludeAssemblies)" WorkingDirectory="$(WorkingDirectory)" />

The project is referencing ILRepack.MSBuild.Task 2.0.13, but I also tried earlier versions with the same result but different error message:

error MSB4036: The "ILRepack" task was not found. Check the following: 1.) The nam
e of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Program Files\dotnet\sdk\7.0.201" directory.

@chejunkie
Copy link

chejunkie commented Apr 16, 2023

I could not get ILRepack to work, but there was a more recent nuget that did the trick:

https://www.nuget.org/packages/ILRepack.Lib.MSBuild/2.1.18/

However, VS2022 still will not recognize the different DLL namespaces that were merged although dotPeek has no problem reading them and their contents.

EDIT: I eventually got VS2022 to recognize the merged namespaces. In my case, it has something to do with the new console template for .net6 that uses top level statements. As soon as I went back to the old style, with a Program class and Main method, VS2022 was able to pickup the merged name spaces and their contents correctly in the console app I was using for testing.

This other repack also works:

https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task

(It is a little nicer, in my opinion, as you are able to modify targets and post build task.)

@aalmada
Copy link
Author

aalmada commented Jul 13, 2023

Any chance this can work in .net 6.0? Works fine locally in VS 2022, but get this error in Azure Devops.

vmimage: windows-latest

I have the same issue with GitHub Actions. It works fine locally using ILRepack.MSBuild.Task on Visual Studio 2022.

Action report: https://github.com/NetFabric/NetFabric.Hyperlinq.Analyzer/actions/runs/5542153526/jobs/10116466992?pr=66

@KirillOsenkov
Copy link
Collaborator

This should work fine with the latest ILRepack version: https://www.nuget.org/packages/ILRepack/2.0.23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants