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

Port GenFacades, Microsft.Cci.Extensions to Arcade #477

Merged
merged 20 commits into from
Sep 12, 2018

Conversation

wtgodbe
Copy link
Member

@wtgodbe wtgodbe commented Aug 16, 2018

This ports GenFacades & Microsft.Cci.Extensions to Arcade. It does the following things:

For #185.

@joperezr @jcagme @chcosta @tmat @weshaggard PTAL

I'd also love ideas on the best way to test this package out in CoreFx.

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 16, 2018

The most interesting files are the .csproj/.targets files, and maybe GenFacadesTask.cs, as well as the general layout/naming scheme I've chosen (which is all described in the PR description)

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 17, 2018

error : Zip Container 'packages\NonShipping\Microsoft.DotNet.GenFacades.1.0.0-ci.nupkg' has part 'tools/netstandard2.0/Microsoft.Cci.dll' which is not listed in the sign or external list

@jcagme do you know what list I need to edit here?

@joperezr
Copy link
Member

@jcagme do you know what list I need to edit here?

eng/SignToolData.json

@jcagme
Copy link
Contributor

jcagme commented Aug 17, 2018

Is the plan for this to end up in myget? If yes then go ahead and add it to eng/SignToolData.json if not we should have a conversation

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 17, 2018

Yes, the plan is for it to wind up in myget.

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

<PackageReference Include="Microsoft.Composition" Version="1.0.30" />
<PackageReference Include="System.Diagnostics.Contracts" Version="4.0.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.0.0" />
<PackageReference Include="NETStandard.Library" Version="1.6.0" />

This comment was marked as spam.

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>

This comment was marked as spam.

@weshaggard
Copy link
Member

I'd also love ideas on the best way to test this package out in CoreFx.

You likely need to hack the targets locally to reference your targets instead of the ones in Buildtools.

@chcosta
Copy link
Member

chcosta commented Aug 23, 2018

fyi @StephenBonikowsky

</PropertyGroup>

<PropertyGroup>
<NoWarn>NU1701</NoWarn>

This comment was marked as spam.

This comment was marked as spam.

@@ -4,12 +4,15 @@
"certificate": "MicrosoftSHA2",
"strongName": "MsSharedLib72",
"values": [
"bin/Microsoft.Cci.Extensions/net461/Microsoft.Cci.Extensions.dll",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 23, 2018

Updated to address feedback. Working on local CoreFx testing now.

@JohnTortugo
Copy link
Contributor

JohnTortugo commented Aug 23, 2018 via email

@@ -1,16 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>

This comment was marked as spam.

@weshaggard
Copy link
Member

Removes partialfacades.exe.targets in favor of partialfacades.task.targets

Why did you remove the exe support? I'm unsure if there are any existing cases for the exe but it does provide some level of flexibility.

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 23, 2018

@weshaggard I didn't believe there were any remaining uses of it. I'm not opposed to adding it back if we want to keep the functionality just in case.

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 23, 2018

Currently getting the following when building with this in CoreFx, I'm investigating:

E:\code\corefx\packages\microsoft.dotnet.genfacades\1.0.0-dev\PackageFiles\partialfacades.targets(97,5): error : Arithmetic operation resulted in an overflow. [E:\code\corefx\src\System.Threading.Tasks.Extensions\ref\System.Threading.Tasks.Extensions.csproj]

@weshaggard
Copy link
Member

@weshaggard I didn't believe there were any remaining uses of it. I'm not opposed to adding it back if we want to keep the functionality just in case.

I'm ok excluding the exe version for now to make things easier, if we find we need it we can add it.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup Condition="'$(GeneratePlatformNotSupportedAssembly)' == 'true' OR '$(GeneratePlatformNotSupportedAssemblyMessage)' != ''">

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 29, 2018

The error is happening here:

writer.Write((DWORD)(productVersion.Build << 16) | (uint)productVersion.Revision);

@wtgodbe
Copy link
Member Author

wtgodbe commented Aug 31, 2018

productVersion.Build is equal to -1 here, which causes the overflow when we try to do productVersion.Build << 16. Could just be due to Arcade's versioning.

@wtgodbe
Copy link
Member Author

wtgodbe commented Sep 4, 2018

This happens on System.Threading.Tasks.Extensions in CoreFx, which has a _productVersionContents of "4.6.26823.0 @BuiltBy: wigodbe-WILLPC @Branch: master @SrcCode: https://github.com/dotnet/corefx/tree/e1a33f4a1cc582f42bd5ae0f887bf1aa9878d493". We then call Version.TryParse() on that value at

if (!Version.TryParse(_productVersionContents, out productVersion))
.

We then go into https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/Version.cs#L322-L391. We then find the indices of the three periods within the version string, but then we hit https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/Version.cs#L343. Since the __productVersionContents contains additional periods, we return null. Therefore, ProductVersion is set to a new Version(0, 0) -

productVersion = new Version(0, 0);
. In Version.cs, Build and Revision are initialized to -1 unless otherwise set: https://github.com/dotnet/corefx/blob/master/src/Common/src/CoreLib/System/Version.cs#L23-L24. Which causes our exception when we try to left-shift productVersion.Build by 16 at
writer.Write((DWORD)(productVersion.Build << 16) | (uint)productVersion.Revision);
. I'm not sure why this isn't happening in normal builds of corefx - looking now.

@wtgodbe
Copy link
Member Author

wtgodbe commented Sep 7, 2018

In the current state, shims.proj fails when calling GenFacades.exe. Debugging.

@wtgodbe
Copy link
Member Author

wtgodbe commented Sep 7, 2018

Looks like I'm missing hostpolicy.dll, which doesn't get packaged with GenFacades.exe, or placed into its bin dir. I borrowed hostpolicy.dll from another location in Arcade & placed it into CoreFx's Tools dir, and got Could not resolve CoreCLR path. Detail dump below:

Using E:\code\corefx\Tools\Microsoft.DotNet.GenFacades.Console.deps.json deps file
Could not locate the dependencies manifest file [E:\code\corefx\Tools\Microsoft.DotNet.GenFacades.Console.deps.json]. Some libraries may fail to resolve.

There is no Microsoft.DotNet.GenFacades.Console.deps.json built in Arcade.

Some earlier (unrelated) command during build was able to successfully set the CoreClr location to E:\code\corefx\Tools\dotnetcli\shared\Microsoft.NETCore.App\2.1.3-servicing-26708-02.

If I place the contents of that folder into Tools, the execution of GenFacades.exe works, but then I get a string of APICompat failures:

E:\code\corefx\Tools\ApiCompat.targets(72,5): error : ApiCompat failed for 'E:\code\corefx\bin\Windows_NT.AnyCPU.Debug\System.Security.Principal.Windows\netcoreapp\System.Security.Principal.Windows.dll' [E:\code\corefx\src\System.Security.Principal.Windows\src\System.Security.Principal.Windows.csproj]
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Cci.Extensions, Version=999.999.999.999, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

@weshaggard
Copy link
Member

Looks like I'm missing hostpolicy.dll, which doesn't get packaged with GenFacades.exe, or placed into its bin dir. I borrowed hostpolicy.dll from another location in Arcade & placed it into CoreFx's Tools dir, and got Could not resolve CoreCLR path.

hostpolicy isn't supposed to come with the exe. This is just an indication that you are missing the runtime you are trying to run on. What is your runtimeconfig file say is the runtime you are trying to run on? As any asside we currently override the runtimeconfig file as part of init-tools.sh (https://github.com/dotnet/buildtools/blob/master/src/Microsoft.DotNet.Build.Tasks/PackageFiles/init-tools.ps1#L11) so we might need to figure out another solution. Perhaps a roll-forward policy.

@wtgodbe
Copy link
Member Author

wtgodbe commented Sep 7, 2018

I don't see a runtimeconfig for GenFacades in Tools or in Arcade

@weshaggard
Copy link
Member

I don't see a runtimeconfig for GenFacades in Tools or in Arcade

There is definitely a GenFacades.runtimeconfig.json file in Tools directory today. It gets generated as part of the build if there isn't one present. We may need to play with it a little to see what our best option is.

@wtgodbe
Copy link
Member Author

wtgodbe commented Sep 12, 2018

Working on converting the call to the .exe in shims.proj to a call to the task. Currently hitting the arithmetic overflow again (only in shims, strangely). Debugging now.

@wtgodbe
Copy link
Member Author

wtgodbe commented Sep 12, 2018

I was able to get this working with CoreFx with a few minor tweaks. For one, shims.proj now looks like this: https://github.com/wtgodbe/corefx/blob/Shims/src/shims/shims.proj

We will probably also need a change to https://github.com/dotnet/buildtools/blob/master/src/Microsoft.DotNet.Build.Tasks/PackageFiles/Build.Common.targets#L220, perhaps adding a property called PartialFacadesFile that defaults to $(MSBuildThisFileDirectory)partialfacades.targets. We could then overwrite that property in CoreFx with the location of the version of the file restored from Arcade.

Also, we'll probably want to wait until we port GenApi/ApiCompat (which I'm going to do next) before consuming this in CoreFx, since otherwise the version of Microsoft.Cci.Extensions that GenFacades depends on will conflict with the version that ApiCompat depends on (I had to resolve this by keeping both versions of the .dll in 2 separate locations when I was hacking CoreFx together).

@weshaggard is there anything else I need to address here?

if (!Version.TryParse(_fileVersionContents, out fileVersion))
// For the File & Product Version, we take the first portion of the string before any whitespace,
// in case there is extraneous information (e.g. '@BuiltBy') after the version number.
if (!Version.TryParse(_fileVersionContents.Split(null)[0], out fileVersion))

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

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

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>

This comment was marked as spam.

Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other then the last couple comments the change looks good overall. I'm fine with you getting this in and then making any necessary changes to start consuming it in corefx as a follow-up.

@wtgodbe wtgodbe merged commit 04f4b34 into dotnet:master Sep 12, 2018
@wtgodbe wtgodbe changed the title [WIP] Port GenFacades, Microsft.Cci.Extensions to Arcade Port GenFacades, Microsft.Cci.Extensions to Arcade Sep 12, 2018
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.

None yet

6 participants