Bug 53310 - Encountering Error CS0012 The type `System.Attribute' is defined in an assembly that is not referenced when trying to build an xunit lib with msbuild
Summary: Encountering Error CS0012 The type `System.Attribute' is defined in an assem...
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: 4.8.0 (C9)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Ankit Jain
Depends on:
Reported: 2017-03-14 14:19 UTC by Peter Collins
Modified: 2017-03-14 18:01 UTC (History)
3 users (show)

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

test case (5.55 KB, application/zip)
2017-03-14 14:19 UTC, Peter Collins

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:

Description Peter Collins 2017-03-14 14:19:43 UTC
Created attachment 20310 [details]
test case

The following error appears to be new, and is only reproducible using msbuild (from both command line and XS). This error did not previously manifest with msbuild in mono-4.8.0, and appears to be a regression in the latest commit[0] based on auto test result history.

> /Users/peter/Projects/TestXunit/TestXunit/MyClass.cs(4,4): Error CS0012: The type `System.Attribute' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' (CS0012) (TestXunit)
[0] https://github.com/mono/mono/commit/8f6d0f67f7b80e03f7fc5c9b695531948ede0410

## Steps to reproduce ##
1) Download the attached project.
2) Load the project in XS (ensure msbuild is enabled) and build it.
2) Restore and build from command line:
> $ nuget restore TestXunit/TestXunit.sln 
> $ msbuild TestXunit/TestXunit.sln
## Additional Info ##
Diagnostic build output - https://gist.github.com/pjcollins/257ab3f72b6520d151d47f44ecbfb37e

## Environment ##
Operating System: Mac OS X 10.11.5
Repo Name: mono.git
Branch Name: mono-4.8.0
Build Revision: 8f6d0f67f7b80e03f7fc5c9b695531948ede0410
Comment 1 Ankit Jain 2017-03-14 15:48:31 UTC
Fixed in 4.9.x - https://github.com/xamarin/bockbuild/commit/3609dac69598f10fbfc33281289c34772eef4350 .

Without this patch, many projects will break like this.