-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
<AutoGenerateBindingRedirects> doesn't work for class libraries #1310
Comments
//cc @ericstj |
cc @piotrpMSFT @krwq @dsplaisted There is a similar requirement for the CLI team |
Also there need to be a way how to specify the target framework for which the redirects need to be generated. Is there is a way to do so for a class library? |
this issue is blocking me from using Microsoft.AspNetCore.TestHost in a .net 4.6.1 test project targeting asp.net core .net 4.6.1 in VS 2017. Manually adding the binding redirect attributes to my test proj doesn't help. :( |
The magic sauce seems to be to add
but I don't understand why there are two props with basically the same meaning. I found this here and then my libraries started generating binding redirects. |
But now it stopped working again.... totally inconsistent behavior :( |
Oh yes it does. I've figured it out. ;) When set the below on a library project
(1) If there are no binding conflicts then the *.config file is not generated. |
Over here I tried to activate both Also, no effect either in library or exe file. Like... redirects not created at all. |
If you don't need the binding redirects then it will not generate them. At least that is what I have found. |
I need them. That's why my software does not start. |
I am also suffering from this. I get the MSB3276 warning, but adding
Does nothing... I am using the new MSBuild-based tooling (that means, using |
This should work: <Target Name="ForceGenerationOfBindingRedirects"
AfterTargets="ResolveAssemblyReferences"
BeforeTargets="GenerateBindingRedirects"
Condition="'$(AutoGenerateBindingRedirects)' == 'true'">
<PropertyGroup>
<!-- Needs to be set in a target because it has to be set after the initial evaluation in the common targets -->
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
</Target> |
tmat, it does work, thank you! |
Yes, there should be a .dll.config file generated to the output directory. |
Fixing this (not requiring any specific output type) is required to unblock microsoft/vstest#792 |
tmat, although I said it worked earlier, I was mistaken, I had changed the command line directory to another project and didn't realize I was building something that didn't have MSB3276 to begin with. At this point, I am still getting that warning, even when using the |
To be honest, I think what I am experiencing is an issue with the warning showing up even when the binding redirection is being done...so the warning trigger is being too sensitive... I do get the I might have to find a more appropriate issue to discuss this... thanks for the help so far, though! |
@tmat Your solution worked for me... thank you so much! So now the redirects are created. Surprising to see how many... I envision it's going to be a hard time to work with .NET Standard libraries. Based on the fallacy of interoperability between frameworks and platforms.... |
It shouldn't need to be set in a target since the common targets only set it to true, never to false (am I missing something?). |
I am aware it worked for others. But for me the only thing that worked was setting it with the target solution @tmat proposed. The rest did not generate any binding at all. |
To understand why static properties might be different than the target you can look at the evaluated project by using msbuild /pp. I suspect that the order of import and/or the contents of the targets themselves differs between the projects. |
/cc @bradwilson |
I sure wish I had found this last month. I must have spent 60 hours working around it. How is this still a thing four years later? Must be trickier to fix than it seems. |
Hi , i am using .net framework sdk style test project which has 3 project references 2- .net standards , 1- .net framework which is also converted to sdk style . I have added these in the unit test project but still the compiler throws the below warnings
|
Thanks tmat, it helped me to get things going again after a lot frustration. For me it helped to get rid of version errors about packages. I was working on a WCF-service on .net 4.8. What I did was remove packages and redirects from web.config, to start with a clean slate. Thinking I could regenerate necessary redirects when re-adding packages. That did not happen. Now the target method gave me the redirects in a dll.config. I think they did not have effect there, but by copying them to web.config they did. Now I had a working situation, even without having to re-add packages, with some recreated redirects (apparently dependencies), but with different version numbers. Apparently there had been a lot to sort out. This may also have been working in an API service, but then directly through the dll.config. I am not sure, but I suddenly lost warnings about redirects while building. |
but what to do if it doesn't help? |
@EgoPingvina Binding redirects as a concept do not apply to .NET 5.0 (and didn't apply to .NET Core). .NET 5.0 will load according to its own rules. It sounds like in your case the copy of |
@rainersigwald but I use |
Correct: You might find the techniques described in this doc on assembly-load debugging helpful for your situation. |
sounds sad. and is it real to fix this problem on .Net 5? |
It's actually not. Most of the time you never need to think about assembly binding rules on .NETCore. The runtime will typically allow a newer version to win. The exceptions are if you're trying to downgrade a dependency or implement a plugin host. There's a of assumptions being tacked onto an existing issue here. Perhaps you can open a new issue with a simple repro? Might be a better way for folks to have a look at what you are facing and make a suggestion to fix it (or identify a unique bug if that's the case). |
The property is ignored unless the containing project is an .exe.
Extensible frameworks/apps that load plugins might support loading configuration for each plugin, including binding redirects, from a .dll.config file next to the plugin .dll. For example, a unit-testing framework such as xunit. See also proposal #1309, which might also make use of this feature.
I propose the restriction on project type is removed and binding redirects are generated for any project that sets AutoGenerateBindingRedirects to true.
The text was updated successfully, but these errors were encountered: