Skip to content

Generate binding redirects for .NET 4.7.2+ - #2885

Merged
rainersigwald merged 2 commits into
dotnet:vs15.6from
rainersigwald:auto-binding-redirects-4.7.2
Jan 23, 2018
Merged

rainersigwald merged 2 commits into
dotnet:vs15.6from
rainersigwald:auto-binding-redirects-4.7.2

Conversation

@rainersigwald

Copy link
Copy Markdown
Member

In The Old Days, binding redirect generation was set to off-by-default.
That has caused a great deal of confusion because it's usually the right
thing to do but it's not obvious when you need to do it.

Unfortunately, we currently think we can't change the default for all
projects, because a user could have been avoiding binding redirects
intentionally, making creating them a breaking change.

Since no projects currently target .NET Framework 4.7.2 (since it's not
released), it is not a breaking change to turn on binding redirects by
default for this (and higher) versions--a user must explicitly opt into
targeting the framework and thus into this new behavior.

A user can still specify

<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>

to explicitly opt out of binding redirects for a given project.

Closes #2481, in partial support of

https://github.com/dotnet/designs/blob/2be39b7e1bc9c4df45b1d51ebb2d1abb0689e4e0/accepted/automatic-redirects-by-default/automatic-redirects-by-default.md

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.

Another reference to TargetFrameworkVersion.Substring(1) indicates that there's not always a leading "v".

https://github.com/Microsoft/msbuild/blob/master/src/Tasks/Microsoft.Common.CurrentVersion.targets#L1898-L1899

Does this need similar logic?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't know why that logic is the way it is. All the other comparisons assume it starts with a v. But yeah, should be cautious.

@rainersigwald
rainersigwald changed the base branch from master to vs15.6 January 23, 2018 18:22
@rainersigwald

Copy link
Copy Markdown
Member Author

I confirmed that these worked with a private internal .NET 4.7.2 developer pack by creating a new project and referencing

    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
    <PackageReference Include="WindowsAzure.Storage" Version="7.2.1" />

Then removing the NuGet-altered binding redirects, removing the template binding redirect generation, and confirming that binding redirects still got created.

In The Old Days, binding redirect generation was set to off-by-default.
That has caused a great deal of confusion because it's usually the right
thing to do but it's not obvious when you need to do it.

Unfortunately, we currently think we can't change the default for all
projects, because a user could have been avoiding binding redirects
intentionally, making creating them a breaking change.

Since no projects currently target .NET Framework 4.7.2 (since it's not
released), it is not a breaking change to turn on binding redirects by
default for this (and higher) versions--a user must explicitly opt into
targeting the framework and thus into this new behavior.

A user can still specify

```xml
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
```

to explicitly opt out of binding redirects for a given project.

Closes dotnet#2481, in partial support of

https://github.com/dotnet/designs/blob/2be39b7e1bc9c4df45b1d51ebb2d1abb0689e4e0/accepted/automatic-redirects-by-default/automatic-redirects-by-default.md
Fixes dotnet#2886 by stripping either case of `v` from
`$(TargetFrameworkVersion)` in a single call.
@rainersigwald
rainersigwald force-pushed the auto-binding-redirects-4.7.2 branch from 1819a47 to f388fc5 Compare January 23, 2018 21:56
@rainersigwald rainersigwald reopened this Jan 23, 2018
@rainersigwald

Copy link
Copy Markdown
Member Author

@dotnet-bot test this please

@rainersigwald

Copy link
Copy Markdown
Member Author

fyi @dsplaisted this carries a fix for #2886.

@rainersigwald
rainersigwald merged commit 01ccf76 into dotnet:vs15.6 Jan 23, 2018
@rainersigwald
rainersigwald deleted the auto-binding-redirects-4.7.2 branch January 23, 2018 23:29

@terrajobst terrajobst left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It looks good to me but I don't think it addresses the perf concerns regarding running more data through RAR when building class libraries.

<PropertyGroup>
<GenerateBindingRedirectsOutputType Condition="'$(OutputType)'=='exe' or '$(OutputType)'=='winexe'">true</GenerateBindingRedirectsOutputType>
<!-- It would be a breaking change to automatically turn on binding redirects for existing projects, so turn them on only when opting into a new framework. -->
<AutoGenerateBindingRedirects Condition="'$(AutoGenerateBindingRedirects)' == '' and '$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(TargetFrameworkVersion.TrimStart(vV))' >= '4.7.2'">true</AutoGenerateBindingRedirects>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What about class libraries? We talked about not wanting to turn this feature on for class libraries unless they are unit test projects.

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.

5 participants