Skip to content

Conversation

@tannergooding
Copy link
Member

This adds the basic support for an ilproj sdk. The IL compilation target was taken from the CoreFX IL.targets

@tannergooding
Copy link
Member Author

FYI. @weshaggard

@tannergooding
Copy link
Member Author

A bare bones ilproj would look like:

<?xml version="1.0"?>
<Project Sdk="Microsoft.NET.Sdk.IL">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

</Project>

I validated locally that this works with System.Runtime.CompilerServices.Unsafe.ilproj

@tannergooding
Copy link
Member Author

The SDK doesn't have all the support required to open an ilproj in VS, but that can always be added in the future (if desired).

<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata minClientVersion="2.8.1">
<id>Microsoft.DotNet.Sdk.IL</id>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@tannergooding
Copy link
Member Author

Also CC. @eerhardt

</PropertyGroup>

<PropertyGroup>
<OSPlatform Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))">win</OSPlatform>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

</PropertyGroup>

<ItemGroup>
<PackageReference Include="$(IlasmPackageName)" Version="$(IlasmPackageVersion)" />

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


<_KeyFileArgument Condition="'$(KeyOriginatorFile)' != ''">-KEY=$(KeyOriginatorFile)</_KeyFileArgument>

<_IlasmSwitches>-QUIET -NOLOGO</_IlasmSwitches>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

</PropertyGroup>

<PropertyGroup>
<OSPlatform Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))">win</OSPlatform>

This comment was marked as spam.

This comment was marked as spam.

<Target Name="CreateManifestResourceNames"
Condition="'@(EmbeddedResource)' != ''"
DependsOnTargets="$(CreateManifestResourceNamesDependsOn)">
<!-- Required by Microsoft.Common.targets -->

This comment was marked as spam.

This comment was marked as spam.

</Exec>
<Error Text="ILAsm failed" Condition="'$(_ILAsmExitCode)' != '0'" />

<CallTarget Targets="$(TargetsTriggeredByCompilation)" Condition="'$(TargetsTriggeredByCompilation)' != ''"/>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


<PropertyGroup>
<MSBuildAllProjects>$(MSBuildThisFileFullPath);$(MSBuildAllProjects)</MSBuildAllProjects>
<LanguageTargets Condition="'$(MSBuildProjectExtension)' == '.ilproj'">$(MSBuildThisFileDirectory)..\build\Microsoft.NET.Sdk.IL.targets</LanguageTargets>

This comment was marked as spam.

This comment was marked as spam.


WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.

This comment was marked as spam.

This comment was marked as spam.

@weshaggard
Copy link
Member

@RussKeldorph PTAL we are doing some work to create a package for ilprojs.

<RuntimeIdentifier>$(OSPlatform)-$(OSArchitecture.ToLower())</RuntimeIdentifier>
<CoreCLRPackageName>runtime.$(RuntimeIdentifier).microsoft.netcore.runtime.coreclr</CoreCLRPackageName>
<IlasmPackageName>runtime.$(RuntimeIdentifier).microsoft.netcore.ilasm</IlasmPackageName>
<IlasmPackageVersion>2.0.8</IlasmPackageVersion>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


<ItemGroup>
<PackageReference Include="$(IlasmPackageName)" Version="$(IlasmPackageVersion)" />
<PackageReference Include="$(CoreCLRPackageName)" Version="$(IlasmPackageVersion)" />

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


<Error Condition="'$(ToolsDir)' == ''" Text="ToolsDir must be set in order to build ilproj's" />
<MakeDir Directories="$(ToolsDir)\ilasm" />
<Copy DestinationFolder="$(ToolsDir)\ilasm" SourceFiles="@(_IlasmSourceFiles)" />

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="$(MSBuildThisFileDirectory)..\build\Microsoft.NET.Sdk.IL.props" Condition="'$(MSBuildProjectExtension)' == '.ilproj'" />

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@RussKeldorph
Copy link
Contributor

@chsienki @AaronRobinsonMSFT FYI

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.0</TargetFrameworks>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

<RuntimeIdentifier>$(OSPlatform)-$(OSArchitecture.ToLower())</RuntimeIdentifier>
<CoreCLRPackageName>runtime.$(RuntimeIdentifier).microsoft.netcore.runtime.coreclr</CoreCLRPackageName>
<IlasmPackageName>runtime.$(RuntimeIdentifier).microsoft.netcore.ilasm</IlasmPackageName>
<IlasmPackageVersion>2.0.8</IlasmPackageVersion>

This comment was marked as spam.

@tannergooding
Copy link
Member Author

Resolved the majority of feedback so far (that isn't part of secondary refactoring/cleanup work)

<OSPlatform Condition="$([MSBuild]::IsOSPlatform('linux'))">linux</OSPlatform>
<OSPlatform Condition="$([MSBuild]::IsOSPlatform('osx'))">osx</OSPlatform>
<OSArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)</OSArchitecture>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">$(OSPlatform)-$(OSArchitecture.ToLower())</RuntimeIdentifier>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

</PropertyGroup>

<PropertyGroup>
<OSPlatform Condition="$([MSBuild]::IsOSPlatform('windows'))">win</OSPlatform>

This comment was marked as spam.

This comment was marked as spam.

<IlasmPackageRuntimeId Condition="'$(IlasmPackageRuntimeId)' == ''">$(OSPlatform)-$(OSArchitecture.ToLower())</IlasmPackageRuntimeId>
<CoreCLRPackageName>runtime.$(IlasmPackageRuntimeId).microsoft.netcore.runtime.coreclr</CoreCLRPackageName>
<IlasmPackageName>runtime.$(IlasmPackageRuntimeId).microsoft.netcore.ilasm</IlasmPackageName>
<IlasmPackageVersion Condition="'$(IlasmPackageVersion)' == ''">2.0.8</IlasmPackageVersion>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

<_IlasmSourceFiles Include="$(NuGetPackageRoot)\$(CoreCLRPackageName)\$(IlasmPackageVersion)\runtimes\$(IlasmPackageRuntimeId)\native\**\*" />
</ItemGroup>

<Error Condition="'$(ToolsDir)' == ''" Text="ToolsDir must be set in order to build ilproj's" />

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


<ItemGroup>
<None Include="sdk/*.*" Pack="true" PackagePath="sdk/%(Filename)%(Extension)" />
<None Include="build/*.*" Pack="true" PackagePath="build/%(Filename)%(Extension)" />

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@eerhardt
Copy link
Member

eerhardt commented Jul 12, 2018

Have we given any thought to how source-build and bootstrapping a new platform will work with these changes?

Check out: https://github.com/dotnet/source-build/blob/master/Documentation/boostrap-new-os.md#use-the-bootstrap-cli-to-build-source-build for some hack workarounds I needed to do with ILAsm when trying to bootstrap a platform.

One concern here is the ordering of the repos during source-build. The way we have it today is that roslyn-tools (i.e. the current 'arcade') is built first, but here are we directly dependent on coreclr. I'm wondering how someone could fix a bug in ILAsm, and then use source-build to build the product again. How could someone tell this new IL SDK package to use the local ILAsm package that they just built themself?

NOTE: this initial PR doesn't need to block on this comment, just putting up some "food for thought".

@tannergooding
Copy link
Member Author

How could someone tell this new IL SDK package to use the local ILAsm package that they just built themself?

I would presume that CoreCLR builds the package and puts it into the source build feed. Source build when then consume said package from the source build feed (it should be no different from dogfooding any other native tool from the toolchain).

@eerhardt
Copy link
Member

I would presume that CoreCLR builds the package and puts it into the source build feed. Source build when then consume said package from the source build feed

But the way you have it coded, your package uses the 2.0.8 version. Who will tell it to use the one that is in the source build feed?

@tannergooding
Copy link
Member Author

But the way you have it coded, your package uses the 2.0.8 version.

It's conditionalized so anyone can override it. That being said, it isn't following the standard naming convention, which I'll update.

@tannergooding
Copy link
Member Author

Updated as per the new feedback so far.

@weshaggard
Copy link
Member

I would presume that CoreCLR builds the package and puts it into the source build feed. Source build when then consume said package from the source build feed (it should be no different from dogfooding any other native tool from the toolchain).

Is there any reason we don't just put it in coreclr to start with?

@tannergooding
Copy link
Member Author

Is there any reason we don't just put it in coreclr to start with

ILAsm and the ILAsm package are both in CoreCLR and produced from there already... Unless you are asking about this SDK package?

@weshaggard
Copy link
Member

Unless you are asking about this SDK package?

Yes I'm referring to the sdk package. Ideally we can keep everything together. We could even potentially turn the root Microsoft.NETCore.Ilasm package into the sdk package.

@tannergooding
Copy link
Member Author

tannergooding commented Jul 13, 2018

We could even potentially turn the root Microsoft.NETCore.Ilasm package into the sdk package.

I'm not sure if that is desirable.

ilasm is a good choice for a standalone tool, and it probably shouldn't be only shipped within the ilproj SDK. If we moved it into CoreCLR, I think we would want to have both the ilasm standalone package and the ilproj SDK.... I think it might be a good idea to also ship the ilasm tool direclty in the ilproj SDK (rather than downloading it via a pkgref), however.

@eerhardt
Copy link
Member

Compare it to our other compiler NuGet package - https://www.nuget.org/packages/Microsoft.NETCore.Compilers/ has csc and vbc in it.

@tannergooding
Copy link
Member Author

Compare it to our other compiler NuGet package - https://www.nuget.org/packages/Microsoft.NETCore.Compilers/ has csc and vbc in it.

Right. The Microsoft.NETCore.Compilers package contains just the tool and supporting targets. It hooks into the existing SDK (via hooks we added to the SDK for C#/VB), when referenced; rather than being a new SDK itself.

@weshaggard
Copy link
Member

@tannergooding at any rate to help with source-build and other such things I think it would be good to have this SDK package build in coreclr instead of arcade so the tools can be built as a prereq for the other higher level repo's needing this.

@tannergooding
Copy link
Member Author

Working on porting this over to CoreCLR. Will close after the new PR is up.

@tannergooding
Copy link
Member Author

Porting to CoreCLR requires a change to build-tools so that the pkgproj in CoreCLR can be marked with PackgeType=MSBuildSdk

@weshaggard
Copy link
Member

Porting to CoreCLR requires a change to build-tools so that the pkgproj in CoreCLR can be marked with PackgeType=MSBuildSdk

That's fine go ahead and make the necessary PR changes.

@tannergooding
Copy link
Member Author

As an update. The BuildTools changes went in: dotnet/buildtools#2100

Just waiting on the changes to be pumped back to CoreCLR now.

@tannergooding
Copy link
Member Author

Replaced by dotnet/coreclr#19066

@tannergooding
Copy link
Member Author

CoreFX side is here: dotnet/corefx#31512

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

Successfully merging this pull request may close these issues.

9 participants