Bug 59451 - Denied assembly replacement not found for net461 project, System.Text.Encoding.CodePages
Summary: Denied assembly replacement not found for net461 project, System.Text.Encodin...
Status: CONFIRMED
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Ankit Jain
URL:
Depends on:
Blocks:
 
Reported: 2017-09-13 12:48 UTC by Ankit Jain
Modified: 2017-10-27 14:40 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
TestConsole.tar.gz (2.71 KB, application/x-gzip)
2017-09-13 12:48 UTC, Ankit Jain
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 59451 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Ankit Jain 2017-09-13 12:48:51 UTC
Created attachment 24727 [details]
TestConsole.tar.gz

msbuild/mono has support for replacing denied assemblies with corresponding ones from Mono.

In a net461 project, msbuild fails to find a replacement for `System.Text.Encoding.CodePages`, giving an error like:

(FilterDeniedAssemblyReferences target) ->
  /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/xbuild/15.0/Microsoft.Common.targets/ImportAfter/Microsoft.Common.Mono.After.targets(25,9): warning MSB3912: INTERNAL WARNING: Could not find the replacement assembly (System.Text.Encoding.CodePages.dll) for the Windows specific reference /Users/ankit/Projects/TestConsole/packages/System.Text.Encoding.CodePages.4.3.0/lib/net46/System.Text.Encoding.CodePages.dll. Please file a bug report at https://bugzilla.xamarin.com .

To reproduce with the attached test project:

 $ nuget restore
 $ msbuild /p:FilterDeniedAssemblies=true

Note that you have to explicitly enable this with `/p:FilterDeniedAssemblies=true`, as it is normally not an issue for a regular .net project. And that is because the mono runtime denies the assembly load but then continues to search for another assembly to satisfy that. But it would be an issue if were to try to bundle the app + dependencies in some form.

The reason it fails is that the search paths used by `FilterDeniedAssemblies` in this case are:

      SearchPaths=
          /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/xbuild-frameworks/.NETFramework/v4.6.1/                                                                                                                                                           
          /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/4.6.1-api/
          /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/4.6.1-api/Facades/
          /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/4.6.1-api/Facades/

And the assembly exists only in /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/4.5/Facades .
Comment 1 Ankit Jain 2017-09-13 12:49:57 UTC
This is related to https://bugzilla.xamarin.com/show_bug.cgi?id=56682 .
Comment 2 Marek Safar 2017-10-27 11:16:57 UTC
This looks like some bad logic in the Task itself. I can see the assembly to be listed correctly at https://github.com/mono/mono/blob/adbf98b977572b6915bb286edb1abb5c2afd0d0e/mcs/tools/xbuild/data/deniedAssembliesList.txt#L14
Comment 3 Ankit Jain 2017-10-27 14:40:30 UTC
Yeah and it is correctly identifying the assembly as a denied one. But it cannot find a replacement. See details in the bug description.