Bug 31271 - Incorrect interpretation of <NoStdLib /> tag
Summary: Incorrect interpretation of <NoStdLib /> tag
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-06-21 11:59 UTC by Avenger
Modified: 2015-12-11 00:36 UTC (History)
5 users (show)

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

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 31271 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:

Description Avenger 2015-06-21 11:59:30 UTC
If you add an additional <PropertyGroup> section to the end of the .csproj file (after the sections with condition '$(Configuration)|$(Platform)' == 'Release|AnyCPU', XamarinStudio will not appropriately use the property in any configuration.

But, if you open the project's options under Build > General, you will see the '[v] Do not reference mscorlib.dll' option checked. Once you click 'ok', XamarinStudio will rewrite the .csproj file with the property on the conditional PropertyGroups, so closing and re-opening the solution will "fix" the problem.

This essentially breaks compatibility with Visual Studio and the side effect of how XamarinStudio "fixes" the issue is obscure. Only thru careful investigation is possible to identify how the property behaves and how to fix it. It should be applied in the first time the project is opened and no changes should be made to the project file.

Steps to reproduce:
1. On windows, Visual Studio (2013) create a new project (Library, console...)
2. Unload the project and edit the project file.
3. To the end of the file, add the following text:
4. Save and re-load project. It should no longer reference to the mscorlib stuff once built nor with intellisense.
5. Close the project and make it accessible to your *nix environment -- this might be reproducible on Windows version of XamarinStudio as well
6. On XamarinStudio, open the project.
7. Try to build it -- notice now it references again to mscorlib.dll.
8. Open the project options dialog, Build > General, change nothing. Just notice the 'mscorlib' option is checked.
9. Close the Options dialog by clicking the 'Ok' button, so it is effectively applied
10. Close and re-open the solution. Upon building, it will no longer reference mscorlib.

I hope this report helps improving user experience with XamarinStudio!

I work on a project that implements mscorlib.dll stuff so I must not allow the IDE to reference it no matter what, that's why this bug was imperative to me.
Comment 1 Avenger 2015-06-21 13:01:21 UTC
This is even worse when the <PropertyGroup> is in an included file.


<Import Project="PRoject.targets" Condition="Exists('project.targets')" />

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

In this case, the checkbox about mscorlib on XamarinStudio's project general build options is not even checked.
Comment 2 Rajneesh Kumar 2015-08-19 07:24:34 UTC
I have checked this issue and able to reproduce the reported behavior. To reproduce this issue i have followed the steps and instruction provided in bug description. I observed that 'mscorlib' option is checked under project options dialog, Build > General.

Screencast: http://www.screencast.com/t/cCRR3zdot

Please let me know that is this the same behavior you are facing at your end? Or I am still missing something to reproduce this issue.

Note: I also observed that I am getting following build error after making changes in project file with XS and VS both.
C:\Users\Rajneesh\Documents\Visual Studio 2013\Projects\TestBug_31271\TestBug_31271\CSC: Error CS0518: Predefined type 'System.Object' is not defined or imported (CS0518) (TestBug_31271)


Id Logs: https://gist.github.com/Rajneesh360Logica/9d911d36375e562cd3d9

Environment Info:

 === Xamarin Studio ===

Version 5.9.5 (build 9)
Installation UUID: 0e0b91ee-55ec-4538-bba2-9b20c10d7c6b
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 5.1.5 (Enterprise Edition)
Android SDK: E:\android-sdk
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
Java SDK: C:\Program Files\Java\jdk1.7.0_71
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 509050009
Git revision: b99cb19a1d3b15d8980c4616f13f837457e5b292
Build date: 2015-07-28 02:41:02-04
Xamarin addins: d53d6eceb828422f3d4aff8547f2f6bab6c9ea58

=== Operating System ===

Windows 6.2.9200.0
Comment 3 Avenger 2015-08-28 13:42:09 UTC
Hello @Rajnesh! Sorry for taking so long to get back to you.

Nice video, I should try this once :)

To me, it looks like you skipped step 7 in my step by step. You just loaded the project and then opened the options dialog.

Once you click 'ok' there (1:03) look at "status bar" (top center of Xamarin) how it says 'project saved'. That's when I believe it 'fixes' the .sln (fixes for itself, heh).

System.object missing is expected to happen when you don't reference mscorlib.

In other words, your build attempt on step 7 might work while build attempt in step 10 might fail for the missing reference to System.object (your new project has sample code trying to use System.object provided by mscorlib).

So it seems in the video you missed exactly the proof that mscorlib is referenced upon opening the project.

I also notice two annoying changes to projects when tracked by git:
1. <NoStdLib>true</NoStdLib> being added to every PropertyGroup in the .csproj files
2. Project UUIDs being converted to uppercase
-      <Project>{de78b8b7-c0f5-415b-a70b-02194433f450}</Project>
+      <Project>{DE78B8B7-C0F5-415B-A70B-02194433F450}</Project>

This at the least makes interoperability with VS annoying. In the project I work with, the priority is Windows support and code specific by Xamarin/Mono is to be avoided.

While the point 2 above is just cosmetic and may be not considered a real bug, but "grumpy behavior" between the two IDEs, I believe the first one can break projects and add redundant information to the .csproj file.

More details on 1, it adds the tag to <PropertyGroup> tags (without condition) and also to the ones with Condition=Debug and =Release.

So I can summarize this into three issues with NoStdLib interpretation:
i. Mono does not recognize the tag if used in an specific, conditionless PropertyGroup tag
ii. Xamarin Studio recognizes the setting but when saving the project, it rewrites the .csproj file spreading the tag on all and any PropertyGroup tags on the file
iii. If the NoSTDLib tag is inside an included file (like .targets), it is not read neither by Mono nor XamarinStudio.

My 'about' stuff:
=== Xamarin Studio ===

Version 5.9.5 (build 10)
Installation UUID: 3a1594ad-47c6-448f-88a5-dea1cf6e1eb0
	Mono 4.0.3 ((detached/d6946b4)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400030020

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Not Installed

=== Xamarin.Android ===

Not Installed

=== Xamarin Android Player ===

Not Installed

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 509050010
Git revision: 48d16bc4f12ce3938964fc7c3d72fdc6887ad4ad
Build date: 2015-08-18 16:55:24-04
Xamarin addins: c2d51b360ad9f59e689046d47030df27de28f94a

=== Operating System ===

Mac OS X 10.10.5
Darwin Fabricios-MacBook-Pro.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 4 Lluis Sanchez 2015-12-10 22:29:19 UTC
This is actually a problem in xbuild. If the NoStdLib property is set before the c# targets import, it works fine. If the property is defined after the import, it is ignored.

The bug that happens when the property is defined in an imported project will be fixed in XS 6.0.
Comment 5 Avenger 2015-12-11 00:36:00 UTC
Thanks! Awesome!!