You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
I got a confusing error message when running PEVerify on an assembly, so I wanted to see if ILVerify fared better but I didn't actually manage to run it and my experience along the way was fairly bad. Here's what I did:
Consult the readme. This doesn't help, there is no information about building or running ILVerify there.
Find the right project. Should I use the one in src/ILVerify/src or the one in src/ILVerify/netcoreapp? The one in netcoreapp seems to be Hello World, so it must be the one in src. Why is the Hello World even there?
Attempt to open the solution in VS. This failed with the cryptic "error : Project file is incomplete. Expected imports are missing.".
Attempt to build the solution with dotnet build. Got an error that I should run init-tools.cmd.
Run init-tools.cmd and then dotnet build again, both succeeded. Though dotnet build produced the following confusing warning:
E:\Users\Svick\git\corert\Tools\packageresolve.targets(93,5): warning : Your project is not referencing the ".NETCoreApp,Version=v2.1" framework. Add a reference to ".NETCoreApp,Version=v2.1" in the "frameworks" section of your project.json, and then re-run NuGet restore.
Try to run the project with dotnet run. Got:
System.ComponentModel.Win32Exception (2): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Microsoft.DotNet.Cli.Utils.Command.Execute()
at Microsoft.DotNet.Tools.Run.RunCommand.Start()
at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
Try to directly run the built dll with dotnet. Got:
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'E:\Users\Svick\git\corert\bin\Windows_NT.x64.Debug\ILVerify'.
Failed to run as a self-contained app. If this should be a framework-dependent app, specify the appropriate framework in E:\Users\Svick\git\corert\bin\Windows_NT.x64.Debug\ILVerify\ILVerify.runtimeconfig.json.
Try to run the project in VS. Got:
Try to rename the dll to exe and run it. Got:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.Metadata, Version=1.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Things that I think should be done:
The build should be fixed (assuming it's actually broken).
Run build.cmd in repo root first. ilverify.exe will be in \corert\bin\Windows_NT.x64.Debug\ILVerify\ILVerify.exe. You can verify that it works by running:
Once you have done build.cmd succesfuly once, you should be able to open the project src\ILVerify\src\ILVerify.csproj in VS and work with it as usual.
The Hello World project should be deleted.
This is glue between the buildtools build system and regular dotnet build system. This can be deleted once corert is converted to SDK projects (like what was done in dotnet/corefx#29831).
@jkotas Thanks, that does work. I still think this could be improved, but I understand if it doesn't make sense to work on that if the build system is going to change.
This is glue between the buildtools build system and regular dotnet build system.
The thing that confused me the most is that the code for that project is literally just Console.WriteLine("Hello world!");. Is that necessary for the glue to work?
(This issue is still open, and the difficulties I'm seeing are similar, so I hope it's okay to add to it.)
I'm trying to run ILVerify and just not having any luck getting things to build. I've tried Windows, Mac, and Linux/WSL.
On Windows, I'm using VS 2017. I've got the prereqs installed. But just trying to run build.cmd gives me:
The system cannot find the batch label specified - CheckMSBuild
Setting build variables failed.
This error is the same whether I am using a plain cmd.exe or a Visual Studio command prompt.
The init-tools.cmd does seem to work. Once I've done that, dotnet build in src/ILVerify/src seems to build something, but dotnet run does not work there. I do get bin\Windows_NT.x64.Debug\ILVerify\ILVerify.dll, but no .exe as described above, and trying to use dotnet to run the dll gives:
A fatal error was encountered. The library 'hostpolicy.dll' required ...
I decided to try Linux/WSL to see if I had more luck there. I got the prereqs installed without incident, But build.sh runs for a little bit and then gives:
So I switched to Mac. This one got the closest, as build.sh seems to be mostly successful. I do get output in bin/OSX.x64.Debug/ILVerify, but trying to run ILVerify.dll gives a dylib-flavored form of the hostpolicy error I saw on Windows.
Activity
jkotas commentedon Aug 9, 2018
Run
build.cmdin repo root first. ilverify.exe will be in\corert\bin\Windows_NT.x64.Debug\ILVerify\ILVerify.exe. You can verify that it works by running:\corert\bin\Windows_NT.x64.Debug\ILVerify\ILVerify.exe %WINDIR%\Microsoft.NET\Framework\v4.0.30319\CasPol.exe -r:%WINDIR%\Microsoft.NET\Framework\v4.0.30319\*.dllOnce you have done
build.cmdsuccesfuly once, you should be able to open the projectsrc\ILVerify\src\ILVerify.csprojin VS and work with it as usual.This is glue between the buildtools build system and regular dotnet build system. This can be deleted once corert is converted to SDK projects (like what was done in dotnet/corefx#29831).
svick commentedon Aug 10, 2018
@jkotas Thanks, that does work. I still think this could be improved, but I understand if it doesn't make sense to work on that if the build system is going to change.
The thing that confused me the most is that the code for that project is literally just
Console.WriteLine("Hello world!");. Is that necessary for the glue to work?jkotas commentedon Aug 10, 2018
The glue just needs a dummy program with the right name to publish. The
Console.WriteLinecan be replaced by a comment that explains what it is for. https://github.com/dotnet/corert/tree/master/src/ILCompiler/netcoreapp is second place where we have the same pattern.ericsink commentedon May 10, 2019
(This issue is still open, and the difficulties I'm seeing are similar, so I hope it's okay to add to it.)
I'm trying to run ILVerify and just not having any luck getting things to build. I've tried Windows, Mac, and Linux/WSL.
On Windows, I'm using VS 2017. I've got the prereqs installed. But just trying to run build.cmd gives me:
This error is the same whether I am using a plain cmd.exe or a Visual Studio command prompt.
The init-tools.cmd does seem to work. Once I've done that,
dotnet buildin src/ILVerify/src seems to build something, butdotnet rundoes not work there. I do get bin\Windows_NT.x64.Debug\ILVerify\ILVerify.dll, but no .exe as described above, and trying to usedotnetto run the dll gives:I decided to try Linux/WSL to see if I had more luck there. I got the prereqs installed without incident, But
build.shruns for a little bit and then gives:So I switched to Mac. This one got the closest, as
build.shseems to be mostly successful. I do get output in bin/OSX.x64.Debug/ILVerify, but trying to run ILVerify.dll gives a dylib-flavored form of the hostpolicy error I saw on Windows.Any tips would be appreciated. Thanks in advance.
abelbraaksma commentedon Mar 4, 2020
@ericsink, I don't have answers for your build issues, but I just noticed (from here: dotnet/roslyn#22872) that there's a private build NuGet package available of the API: https://dotnet.myget.org/feed/dotnet-core/package/nuget/Microsoft.DotNet.ILVerification.
It has the (relatively new) public API described here: #3734
jkotas commentedon Jun 3, 2020
ILVerify was moved to dotnet/runtime repo. It is being published as a global tool. dotnet/runtime#35038 (comment) has an example how it works.