Skip to content

[DONT_MERGE_YET][msbuild][mac][ios] bxc#58504: Fix referencing netstandard projects - #2640

Closed
radical wants to merge 1 commit into
dotnet:d15-4from
radical:xi-xm-fix-ns20-ref-d15-4
Closed

[DONT_MERGE_YET][msbuild][mac][ios] bxc#58504: Fix referencing netstandard projects#2640
radical wants to merge 1 commit into
dotnet:d15-4from
radical:xi-xm-fix-ns20-ref-d15-4

Conversation

@radical

@radical radical commented Sep 11, 2017

Copy link
Copy Markdown
Member

Building a XI or XM (Modern) project that references a netstandard 2.0
project with msbuild fails because of a missing reference to
netstandard.dll.

AppDelegate.cs(21,52): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

The reason is that XI and XM (Modern) projects have
$(TargetFrameworkIdentifier) != .NETFramework, so targets from
Microsoft.NET.Build.Extensions which provide ns2.0 support don't get
imported. ImplicitlyExpandNETStandardFacades in particular, which
would have added a reference to netstandard.dll.

So, instead we duplicate that in XI/XM targets. Essentially, we need to
scan all the references for a netstandard dependency (using
GetDependsOnNETStandard task) and if found, add the netstandard.dll
reference.

Partially fixes bxc 58504.

@rolfbjarne rolfbjarne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but it needs to go into master first.

@radical radical changed the title [msbuild][mac][ios] bxc#58504: Fix referencing netstandard projects [DONT_MERGE_YET][msbuild][mac][ios] bxc#58504: Fix referencing netstandard projects Sep 11, 2017
@radical

radical commented Sep 11, 2017

Copy link
Copy Markdown
Member Author

I found an issue that needs to be fixed first.

@spouliot

Copy link
Copy Markdown
Contributor

Yes, we won't have permission to backport into 15.4 unless it's verified (by QA) in master.

@chamons chamons left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks reasonable enough, but I really would like that XM msbuild test that I wrote for you attached with the fix if possible.

@chamons

chamons commented Sep 11, 2017

Copy link
Copy Markdown
Contributor

@monojenkins

Copy link
Copy Markdown
Contributor

Build failure

Building a XI or XM (Modern) project that references a netstandard 2.0
project with msbuild fails because of a missing reference to
`netstandard.dll`.

AppDelegate.cs(21,52): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

The reason is that XI and XM (Modern) projects have
`$(TargetFrameworkIdentifier) != .NETFramework`, so targets from
`Microsoft.NET.Build.Extensions` which provide ns2.0 support don't get
imported. `ImplicitlyExpandNETStandardFacades` in particular, which
would have added a reference to `netstandard.dll`.

`netstandard.dll` gets included as part of the facades expanded by
`ImplicitlyExpandDesignTimeFacades`, but this gets skipped if the
project does not have a `System.Runtime` dependent reference.

Instead, we want to expand the facades if any reference depends on
`System.Runtime` OR `netstandard`. And for that we scan all the
references for a `netstandard` dependency using the
`GetDependsOnNETStandard` task.

Partially fixes bxc #58504 .
@radical
radical force-pushed the xi-xm-fix-ns20-ref-d15-4 branch from 86457c8 to a975c3e Compare September 11, 2017 14:23
@radical

radical commented Sep 11, 2017

Copy link
Copy Markdown
Member Author

Opened a new PR against master: #2643

@radical radical closed this Sep 11, 2017
@radical
radical deleted the xi-xm-fix-ns20-ref-d15-4 branch September 11, 2017 14:28
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.

6 participants