Bug 55234 - msbuild 15.1 fail to forward PackageReference to msc.exe
Summary: msbuild 15.1 fail to forward PackageReference to msc.exe
Status: RESOLVED FIXED
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: 15.2
Assignee: Ankit Jain
URL:
Depends on:
Blocks:
 
Reported: 2017-04-15 09:21 UTC by Lorenzo Delana
Modified: 2017-04-19 23:20 UTC (History)
1 user (show)

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


Attachments
repro consoleapp1 consoleapp2 (2.69 KB, application/x-gzip)
2017-04-15 09:21 UTC, Lorenzo Delana
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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Lorenzo Delana 2017-04-15 09:21:00 UTC
Created attachment 21561 [details]
repro consoleapp1 consoleapp2

version
=======
15.1.0.0   ( 15.1+xamarinxplat.2017.02.14.47.38-0xamarin1 all )

description
===========
msbuild fail to forward /reference: switch for nuget PackageReference items, regardless /t:restore switch restores them correctly under $(HOME)/.nuget/packages

repro
=====
- compile attached ConsoleApp1 works because it uses packages.config file
- compile attached ConsoleApp2 don't work because /reference: switch not forwarded to the msc.exe build command line

details
=======

compile command : msbuild /t:restore,rebuild

ConsoleApp1
-----------

CoreCompile:
  /usr/lib/mono/4.5/mcs.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:/usr/lib/mono/4.5.2-api/Microsoft.CSharp.dll /reference:/usr/lib/mono/4.5.2-api/mscorlib.dll /reference:/nas/tmp/ConsoleApp1/packages/Newtonsoft.Json.10.0.2/lib/net45/Newtonsoft.Json.dll /reference:/usr/lib/mono/4.5.2-api/System.Core.dll /reference:/usr/lib/mono/4.5.2-api/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.5.2-api/System.Data.dll /reference:/usr/lib/mono/4.5.2-api/System.dll /reference:/usr/lib/mono/4.5.2-api/System.Net.Http.dll /reference:/usr/lib/mono/4.5.2-api/System.Xml.dll /reference:/usr/lib/mono/4.5.2-api/System.Xml.Linq.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj/Debug/ConsoleApp1.exe /subsystemversion:6.00 /target:exe /utf8output Program.cs Properties/AssemblyInfo.cs "/tmp/.NETFramework,Version=v4.5.2.AssemblyAttributes.cs"

note `/reference:/nas/tmp/ConsoleApp1/packages/Newtonsoft.Json.10.0.2/lib/net45/Newtonsoft.Json.dll` correctly added

ConsoleApp2
-----------

CoreCompile:
  /usr/lib/mono/4.5/mcs.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:/usr/lib/mono/4.5.2-api/Microsoft.CSharp.dll /reference:/usr/lib/mono/4.5.2-api/mscorlib.dll /reference:/usr/lib/mono/4.5.2-api/System.Core.dll /reference:/usr/lib/mono/4.5.2-api/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.5.2-api/System.Data.dll /reference:/usr/lib/mono/4.5.2-api/System.dll /reference:/usr/lib/mono/4.5.2-api/System.Net.Http.dll /reference:/usr/lib/mono/4.5.2-api/System.Xml.dll /reference:/usr/lib/mono/4.5.2-api/System.Xml.Linq.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj/Debug/ConsoleApp2.exe /subsystemversion:6.00 /target:exe /utf8output Program.cs Properties/AssemblyInfo.cs "/tmp/.NETFramework,Version=v4.5.2.AssemblyAttributes.cs"
Program.cs(1,7): error CS0246: The type or namespace name `Newtonsoft' could not be found. Are you missing an assembly reference? [/nas/tmp/ConsoleApp2/ConsoleApp2/ConsoleApp2.csproj]

workaround
==========

not really a workaround, but just add /reference:$HOME/.nuget/packages/newtonsoft.json/10.0.2/lib/net45/Newtonsoft.Json.dll allow mcs.exe compilation to work
Comment 1 Ankit Jain 2017-04-19 23:19:52 UTC
`msbuild /t:Restore` does not support `packages.config` which `ConsoleApp1` uses. You will have to use `nuget restore` for that, and then it will build.

For ConsoelApp2, the fix has been merged - https://github.com/mono/mono/pull/4706 .