-
Notifications
You must be signed in to change notification settings - Fork 506
ILCompiler nuget package support #4983
Conversation
| <!-- PackageTargetRuntime needs to be reset because if let unset, it's going to be set to globally configured value | ||
| which will cause the package assets to be placed into runtime/[RID]/lib/[TFM]/ path, instead of lib/[TFM] --> | ||
|
|
||
| <ProjectReference Include="$(PackageSourceDirectory)ILCompiler\src\ILCompiler.csproj" > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need these ProjectReferences at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not specifically.
Ideally, I'd like to use the assemblies generated by these directly instead of including the entire 'tools' folder. I wanted to leave them here mostly so discussion is easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package needs to contain the compiler as published app so that it can run (ie what you would get if you have done dotnet publish ILCompiler.csproj).
The "buildtools" msbuild targets that we are using currently do not support regular publishing easily, so we produce the bits in semi-complicated way. The result is about the same as what you would get by running dotnet publish ILCompiler.csproj ILCompiler.csproj -r <...>.
For the package reference to work well here, it would need to somehow do the publishing. And if the publishing works, it should be sufficient to have just the reference to ILCompiler.csproj since the publishing does transitive closure.
pkg/packageIndex.json
Outdated
| "Microsoft.DotNet.ILCompiler" : { | ||
| "StableVersions": [], | ||
| "BaselineVersion": "1.0.0", | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: there is an extra space on this line.
a95eb72 to
df23f56
Compare
| <!-- PackageTargetRuntime needs to be reset because if let unset, it's going to be set to globally configured value | ||
| which will cause the package assets to be placed into runtime/[RID]/lib/[TFM]/ path, instead of lib/[TFM] --> | ||
|
|
||
| <Dependency Include="Microsoft.DotNet.ObjectWriter"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think ObjectWriter, NetCore.Jit and S.C.Immutable packages needs to be listed here at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And if they need to be here for some reason - they should use versions from https://github.com/dotnet/corert/blob/master/dependencies.props)
2c9282e to
e9959f6
Compare
6248d9e to
9cee186
Compare
samples/WebApi/README.md
Outdated
|
|
||
| Once completed, you can find the native executable in the root folder of your project under ``/bin/x64/<Configuration>/netcoreapp2.0/publish/`` | ||
|
|
||
| ## Try it out! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong tone?
| <TargetOS Condition="'$(TargetOS)' == '' and '$(OS)' == 'Unix' and Exists('/Applications')">OSX</TargetOS> | ||
| <TargetOS Condition="'$(TargetOS)' == ''">$(OS)</TargetOS> | ||
| <!-- Detect whether we're running the ILCompiler from a package and if so override the environmental variable to point to the correct assemblies --> | ||
| <IlcPath Condition="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Microsoft.DotNet.ILCompiler.nuspec)) != ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Microsoft.DotNet.ILCompiler.nuspec))</IlcPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels a bit hacky. There could be a better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be just something like <IlcPath Condition="$(IlcPath) == ''">$(MSBuildThisFileDirectory)/..</IlcPath> ?
75d4664 to
03ad3f7
Compare
|
|
||
| namespace SampleWebApi.Controllers | ||
| { | ||
| public class ValuesController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is incorrect here.
| return new string[] { "value1", "value2" }; | ||
| } | ||
|
|
||
| // This is the method that crashes, which Sergiy and I mentioned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please open an issue to track this problem?
samples/WebApi/SampleWebApi.csproj
Outdated
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this reference? I would remove it to keep the sample project simple.
samples/WebApi/SampleWebApi.csproj
Outdated
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <IlcArg Include="--noscan" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the "--noscan" compiler option should not be necessary after #5040 is merged. I would remove it from the sample.
samples/WebApi/README.md
Outdated
|
|
||
| ``dotnet publish -c <Configuration> -r <RID>`` | ||
|
|
||
| where ``<Configuration>`` is your project configuratio (such as Debug or Release) and ``<RID>`` is the runtime identifier - one of ``win-x64``, ``win-x86``, ``linux-x64`` or ``osx-x64`` depending on the OS you want to publish for. For example, if you want to publish a release configuration of your app for a 64-bit version of Windows the command would look like: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently x86 is not supported by CoreRT. I would remove "win-x86"
samples/WebApi/README.md
Outdated
|
|
||
| where path_to_rdxml_file is the location of the file on your disk. Under the second ``<ItemGroup>`` remove the reference to ``Microsoft.AspNetCore.All`` and substitute it with: | ||
|
|
||
| <PackageReference Include="Microsoft.AspNetCore" Version="2.0.0-preview1-final" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version for ASP.NET packages should be Version="2.0.0". What you have is a pre-release versions.
samples/WebApi/SampleWebApi.csproj
Outdated
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.AspNetCore" Version="2.0.0-preview1-final" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version for ASP.NET packages should be Version="2.0.0".
samples/WebApi/SampleWebApi.csproj
Outdated
| <PackageReference Include="Microsoft.AspNetCore" Version="2.0.0-preview1-final" /> | ||
| <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.0-preview1-final" /> | ||
| <PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.0.0-preview1-final" /> | ||
| <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="1.0.0-alpha-25929-0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is possible, I would not hardcode a specific version of the compiler package. Ideally, the sample should run against the latest published one.
|
@A-And, thank you!
|
|
@sergiy-k Sure thing! Would make certainly make more sense. |
3b3c327 to
aec5771
Compare
aec5771 to
746cfeb
Compare
|
FWIW I gave the package (1.0.0-alpha-25930-03, from yesterday) a try and it seems to be working fine, a native executable is produced. There are a number of linker warnings like: Presumably the .pdb files for native static libraries like runtime.lib should be included in the package as well. The same way that VC++ installs both .lib and .pdb files for its static runtime libraries. |
|
@mikedn Thanks for testing it out! The motivation behind excluding them was to keep the package as minimal as possible, but we should avoid linker warnings if possible. |
| <NativeIntermediateOutputPath Condition="'$(NativeIntermediateOutputPath)' == ''">$(IntermediateOutputPath)native\</NativeIntermediateOutputPath> | ||
| <NativeOutputPath Condition="'$(NativeOutputPath)' == ''">$(OutputPath)native\</NativeOutputPath> | ||
| <NativeCompilationDuringPublish Condition="'$(NativeCompilationDuringPublish)' == ''">true</NativeCompilationDuringPublish> | ||
| <!-- Workaround for lack of current host OS detection - https://github.com/Microsoft/msbuild/issues/539 --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: This issue was fixed - can this be changed to use [MSBuild]::IsOSPlatform() now?
| <TargetOS Condition="'$(TargetOS)' == '' and '$(OS)' == 'Unix' and Exists('/Applications')">OSX</TargetOS> | ||
| <TargetOS Condition="'$(TargetOS)' == '' and '[MSBuild]::IsOSPlatform('OSX')">OSX</TargetOS> | ||
| <TargetOS Condition="'$(TargetOS)' == ''">$(OS)</TargetOS> | ||
| <!-- Detect whether we're running the ILCompiler from a package and if so override the environmental variable to point to the correct assemblies --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reposting https://github.com/dotnet/corert/pull/4983/files/746cfebb4cd9c19f9a7fd7e87c8f3e65c3ee196f..de7a9432439e46dbcbe65677dbf2267b6f44082c#r154461423 to make sure you have seen it:
Can this be just something like $(MSBuildThisFileDirectory)/.. , and remove the Error below?
5707e82 to
64cb37d
Compare
|
@sergiy-k I've manually added the debug symbols for static libraries for now. All .pdbs are already published as part of the nuget symbol package, so we have to consider how a user debugging scenario should work. |
| <NativeOutputPath Condition="'$(NativeOutputPath)' == ''">$(OutputPath)native\</NativeOutputPath> | ||
| <NativeCompilationDuringPublish Condition="'$(NativeCompilationDuringPublish)' == ''">true</NativeCompilationDuringPublish> | ||
| <!-- Workaround for lack of current host OS detection - https://github.com/Microsoft/msbuild/issues/539 --> | ||
| <TargetOS Condition="'$(TargetOS)' == '' and '$(OS)' == 'Unix' and Exists('/Applications')">OSX</TargetOS> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry for not being clear ... I mean to replace this line with the one that is using `[MSBuild]::IsOSPlatform. I suspect that this is why the CI tests on OSX are failing.
|
|
||
| <MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(NativeObject)))" /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extra whitespace
Hmm, it's unlikely that static library .pdbs need to be published, normally the debugger does not look for them, only the linker. Those static .pdbs might be needed during debugging if the And even if it does, this is something that's supposed to work on the developer's machine, where static .pdbs already exist. In "release" scenarios, the .pdb produced by ILC should be a standalone .pdb. The debugger using it is not supposed to need static library .pdbs, .objs or any other intermediate build files. |
3d2605b to
296f798
Compare
|
Sigh, the Windows build is failing with Could you please keep the workaround in place? (Keep the new proper OS detection code around commented out.) |
296f798 to
baff080
Compare
|
@jkotas Thanks for confirming, will do. |
b33ad2c to
c0f7aea
Compare
c0f7aea to
3456f13
Compare
Below is a working implementation - CoreRT can be consumed by adding a
where X is the version of the ILCompiler package produced by build-packages.cmd or once its published with
Ideally, I'd like to add the assemblies produced by the project references in
Microsoft.DotNet.ILCompiler.pkgprojto have theirTargetPathproperty overriden when creating this package specifically, but the paths seem to be dynamically generated somewhere in the compiler. Can anyone more familiar with the NuGet package publishing pipeline take a look?Additionally, the implementation below doesn't include symbols for the framework, sdk and tools assemblies to the final package.