Bug 42356

Summary: msbuild copies reference assemblies which contain no IL to output dir for F# projects
Product: [Mono] Tools Reporter: Alexander Köplinger [MSFT] <alkpli>
Component: msbuildAssignee: Ankit Jain <ankit.jain>
Status: VERIFIED FIXED    
Severity: major CC: benjamin.beckley, danisha, henrik, kyle.white, luis.aguilera, masafa, mono-bugs+tools, peter.collins
Priority: ---    
Version: 4.4.0 (C7)   
Target Milestone: 4.8.0 (C9)   
Hardware: PC   
OS: Mac OS   
Tags: potentialC8SR2 Is this bug a regression?: Yes
Last known good build: 4.2

Description Alexander Köplinger [MSFT] 2016-07-05 12:41:34 UTC
Repro:

- Download https://dl.dropboxusercontent.com/u/21102229/Fakta.zip and unzip
- run "xbuild src/Fakta.sln" and observe output folder
- clean and run "msbuild src/Fakta.sln"

The msbuild one copies a lot more DLL's to the output folder, including framework DLLs like System.Xml.dll and System.Security.dll which should *never* be there (as they're reference assemblies without actual method IL). If the app is executed from there, Mono will try to load these DLLs and blow up.

One problem is that a tool called "albacore" which is used quite frequently in the F# community probes for "msbuild" and uses that if it finds it, which makes this a breaking change when those projects upgrade to Mono 4.4 as "msbuild" now exists.

@radical: I'm contemplating we should rename the msbuild command to "msbuild-preview" to prevent those issues until msbuild got more test coverage. Preferably in C7SR1.

The project in the repro is https://github.com/logibit/Fakta, I just stripped away the rake etc. dependencies so it's easier to test.

Files in output dir with xbuild:

> alexander:~/Desktop/Fakta$ ls -l src/Fakta.Tests/bin/Debug/
> total 12264
> -rw-r--r--  1 alexander  staff    90624  1 Feb 09:34 Aether.dll
> -rw-r--r--  1 alexander  staff      519  5 Jul 13:01 App.config
> -rw-r--r--  1 alexander  staff   350720 21 Mai 15:22 Chiron.dll
> -rw-r--r--  1 alexander  staff   239104 27 Sep  2015 FParsec.dll
> -rw-r--r--  1 alexander  staff   109056 27 Sep  2015 FParsecCS.dll
> -rw-r--r--  1 alexander  staff     6144  5 Jul 14:10 Fakta.Tests.exe
> -rw-r--r--  1 alexander  staff      519  5 Jul 13:01 Fakta.Tests.exe.config
> -rw-r--r--  1 alexander  staff      474  5 Jul 14:10 Fakta.Tests.exe.mdb
> -rw-r--r--  1 alexander  staff  2959360  5 Jul 14:10 Fakta.dll
> -rw-r--r--  1 alexander  staff   475568  5 Jul 14:10 Fakta.dll.mdb
> -rw-r--r--  1 alexander  staff    41136  5 Jul 14:10 Fakta.xml
> -rw-r--r--  1 alexander  staff   610304 20 Apr 21:01 FsCheck.dll
> -rw-r--r--  1 alexander  staff    12800 27 Jan 00:57 Fuchu.FsCheck.dll
> -rw-r--r--  1 alexander  staff   131072 27 Jan 00:57 Fuchu.dll
> -rw-r--r--  1 alexander  staff    51200  1 Jun 08:36 Hopac.Core.dll
> -rw-r--r--  1 alexander  staff   505856  1 Jun 08:36 Hopac.dll
> -rw-r--r--  1 alexander  staff   251392 19 Mai 16:41 HttpFs.dll
> -rw-r--r--  1 alexander  staff   401408 14 Apr 09:29 NodaTime.dll

Files in output dir with msbuild:

> alexander:~/Desktop/Fakta$ ls -l src/Fakta.Tests/bin/Debug/
> total 24928
> -rw-r--r--  1 alexander  staff    90624  1 Feb 09:34 Aether.dll
> -rw-r--r--  1 alexander  staff    97792  1 Feb 09:34 Aether.pdb
> -rw-r--r--  1 alexander  staff    15971  1 Feb 09:34 Aether.xml
> -rw-r--r--  1 alexander  staff      519  5 Jul 13:01 App.config
> -rw-r--r--  1 alexander  staff   350720 21 Mai 15:22 Chiron.dll
> -rw-r--r--  1 alexander  staff   407040 21 Mai 15:22 Chiron.pdb
> -rw-r--r--  1 alexander  staff      636 21 Mai 15:22 Chiron.xml
> -rw-r--r--  1 alexander  staff   239104 27 Sep  2015 FParsec.dll
> -rw-r--r--  1 alexander  staff    88697 27 Sep  2015 FParsec.xml
> -rw-r--r--  1 alexander  staff   109056 27 Sep  2015 FParsecCS.dll
> -rw-r--r--  1 alexander  staff     6782 27 Sep  2015 FParsecCS.xml
> -rw-r--r--  1 alexander  staff  1497088 20 Jun 22:18 FSharp.Core.dll
> -rwxr-xr-x  1 alexander  staff   697699 20 Jun 22:18 FSharp.Core.xml
> -rw-r--r--  1 alexander  staff     6144  5 Jul 14:12 Fakta.Tests.exe
> -rw-r--r--  1 alexander  staff      519  5 Jul 13:01 Fakta.Tests.exe.config
> -rw-r--r--  1 alexander  staff  2959360  5 Jul 14:12 Fakta.dll
> -rw-r--r--  1 alexander  staff    41136  5 Jul 14:12 Fakta.xml
> -rw-r--r--  1 alexander  staff   610304 20 Apr 21:01 FsCheck.dll
> -rw-r--r--  1 alexander  staff   841216 20 Apr 21:02 FsCheck.pdb
> -rw-r--r--  1 alexander  staff    66770 20 Apr 21:01 FsCheck.xml
> -rw-r--r--  1 alexander  staff    12800 27 Jan 00:57 Fuchu.FsCheck.dll
> -rw-r--r--  1 alexander  staff    19968 27 Jan 00:57 Fuchu.FsCheck.pdb
> -rw-r--r--  1 alexander  staff      591 27 Jan 00:57 Fuchu.FsCheck.xml
> -rw-r--r--  1 alexander  staff   131072 27 Jan 00:57 Fuchu.dll
> -rw-r--r--  1 alexander  staff   202240 27 Jan 00:57 Fuchu.pdb
> -rw-r--r--  1 alexander  staff    13526 27 Jan 00:57 Fuchu.xml
> -rw-r--r--  1 alexander  staff    51200  1 Jun 08:36 Hopac.Core.dll
> -rw-r--r--  1 alexander  staff   224768  1 Jun 08:36 Hopac.Core.pdb
> -rw-r--r--  1 alexander  staff    21499  1 Jun 08:36 Hopac.Core.xml
> -rw-r--r--  1 alexander  staff   505856  1 Jun 08:36 Hopac.dll
> -rw-r--r--  1 alexander  staff   693760  1 Jun 08:36 Hopac.pdb
> -rw-r--r--  1 alexander  staff   126547  1 Jun 08:36 Hopac.xml
> -rw-r--r--  1 alexander  staff   251392 19 Mai 16:41 HttpFs.dll
> -rw-r--r--  1 alexander  staff    20054 19 Mai 16:41 HttpFs.xml
> -rwxr-xr-x  1 alexander  staff   136704 20 Jun 21:49 Mono.Posix.dll
> -rwxr-xr-x  1 alexander  staff   146944 20 Jun 21:49 Mono.Security.dll
> -rw-r--r--  1 alexander  staff   401408 14 Apr 09:29 NodaTime.dll
> -rw-r--r--  1 alexander  staff   776335 14 Apr 09:29 NodaTime.xml
> -rwxr-xr-x  1 alexander  staff    84480 20 Jun 21:49 System.Configuration.dll
> -rwxr-xr-x  1 alexander  staff    79360 20 Jun 21:49 System.Security.dll
> -rwxr-xr-x  1 alexander  staff   651776 20 Jun 21:49 System.Xml.dll

Environment:

OSX 10.11
Mono 4.4.1

The initial report we got was https://bugzilla.xamarin.com/show_bug.cgi?id=42248 which I closed as invalid since it seemed to be the common "copy reference assemblies in .target" issue, but turns out it's rather caused by using msbuild inadvertently (which may do the same).
Comment 1 Marek Safar 2016-07-07 17:18:59 UTC
@ankit this is a regression do you have any estimate to which SR we can get a fir for this to?
Comment 3 Marek Safar 2016-08-31 06:07:15 UTC
This issue could be fixed by https://bugzilla.xamarin.com/show_bug.cgi?id=42584
Comment 5 Luis Aguilera 2016-09-12 20:16:29 UTC
since C8 is now closed, and is shipping this week, I will move this but to the C8SR1 milestone. We'll continue working on the issue seeking it's resolution as soon as possible.
Comment 6 Ankit Jain 2017-02-02 23:51:38 UTC
The fix is present in C9/mono 4.8.0 .

Results with mono-4.8.0-branch/135ebee Mon Jan 30 11:54:56 EST 2017:

$ ls -1 src/Fakta.Tests/bin/Debug/
Aether.dll
Aether.pdb
Aether.xml
App.config
Chiron.dll
Chiron.pdb
Chiron.xml
FParsec.dll
FParsec.xml
FParsecCS.dll
FParsecCS.xml
Fakta.Tests.exe
Fakta.Tests.exe.config
Fakta.dll
Fakta.xml
FsCheck.dll
FsCheck.pdb
FsCheck.xml
Fuchu.FsCheck.dll
Fuchu.FsCheck.pdb
Fuchu.FsCheck.xml
Fuchu.dll
Fuchu.pdb
Fuchu.xml
Hopac.Core.dll
Hopac.Core.pdb
Hopac.Core.xml
Hopac.dll
Hopac.pdb
Hopac.xml
HttpFs.dll
HttpFs.xml
NodaTime.dll
NodaTime.xml
Comment 7 Danish Akhtar 2017-02-08 08:07:31 UTC
Reproduce Status:
I am able to reproduce this issue after following the steps mentioned in Bug description with C7 Mono 4.4.0.236 + XS 6.0.2(build 67). Observed that I am getting in output dir with msbuild:
     
Imacs-iMac:~ imac$ cd Desktop/Fakta 
Imacs-iMac:Fakta imac$ cd Fakta/
Imacs-iMac:Fakta imac$ ls -l src/Fakta.Tests/bin/Debug/
total 24928
-rwx------  1 imac  staff    90624 Feb  1  2016 Aether.dll
-rwx------  1 imac  staff    97792 Feb  1  2016 Aether.pdb
-rwx------  1 imac  staff    15971 Feb  1  2016 Aether.xml
-rwx------  1 imac  staff      519 Jul  5  2016 App.config
-rwx------  1 imac  staff   350720 May 21  2016 Chiron.dll
-rwx------  1 imac  staff   407040 May 21  2016 Chiron.pdb
-rwx------  1 imac  staff      636 May 21  2016 Chiron.xml
-rwx------  1 imac  staff   239104 Sep 27  2015 FParsec.dll
-rwx------  1 imac  staff    88697 Sep 27  2015 FParsec.xml
-rwx------  1 imac  staff   109056 Sep 27  2015 FParsecCS.dll
-rwx------  1 imac  staff     6782 Sep 27  2015 FParsecCS.xml
-rw-r--r--  1 imac  staff  1497088 Jul 13  2016 FSharp.Core.dll
-rwxr-xr-x  1 imac  staff   697699 Jul 13  2016 FSharp.Core.xml
-rw-r--r--  1 imac  staff     6144 Feb  8 12:28 Fakta.Tests.exe
-rwx------  1 imac  staff      519 Jul  5  2016 Fakta.Tests.exe.config
-rw-r--r--  1 imac  staff  2959360 Feb  8 12:28 Fakta.dll
-rw-r--r--  1 imac  staff    41136 Feb  8 12:28 Fakta.xml
-rwx------  1 imac  staff   610304 Apr 20  2016 FsCheck.dll
-rwx------  1 imac  staff   841216 Apr 20  2016 FsCheck.pdb
-rwx------  1 imac  staff    66770 Apr 20  2016 FsCheck.xml
-rwx------  1 imac  staff    12800 Jan 27  2016 Fuchu.FsCheck.dll
-rwx------  1 imac  staff    19968 Jan 27  2016 Fuchu.FsCheck.pdb
-rwx------  1 imac  staff      591 Jan 27  2016 Fuchu.FsCheck.xml
-rwx------  1 imac  staff   131072 Jan 27  2016 Fuchu.dll
-rwx------  1 imac  staff   202240 Jan 27  2016 Fuchu.pdb
-rwx------  1 imac  staff    13526 Jan 27  2016 Fuchu.xml
-rwx------  1 imac  staff    51200 Jun  1  2016 Hopac.Core.dll
-rwx------  1 imac  staff   224768 Jun  1  2016 Hopac.Core.pdb
-rwx------  1 imac  staff    21499 Jun  1  2016 Hopac.Core.xml
-rwx------  1 imac  staff   505856 Jun  1  2016 Hopac.dll
-rwx------  1 imac  staff   693760 Jun  1  2016 Hopac.pdb
-rwx------  1 imac  staff   126547 Jun  1  2016 Hopac.xml
-rwx------  1 imac  staff   251392 May 19  2016 HttpFs.dll
-rwx------  1 imac  staff    20054 May 19  2016 HttpFs.xml
-rwxr-xr-x  1 imac  staff   136704 Jul 15  2016 Mono.Posix.dll
-rwxr-xr-x  1 imac  staff   146944 Jul 15  2016 Mono.Security.dll
-rwx------  1 imac  staff   401408 Apr 14  2016 NodaTime.dll
-rwx------  1 imac  staff   776335 Apr 14  2016 NodaTime.xml
-rwxr-xr-x  1 imac  staff    84480 Jul 15  2016 System.Configuration.dll
-rwxr-xr-x  1 imac  staff    79360 Jul 15  2016 System.Security.dll
-rwxr-xr-x  1 imac  staff   651776 Jul 15  2016 System.Xml.dll
Imacs-iMac:Fakta imac$ 

Verified Status:
I have checked this issue with latest C9 Mono 408000487 $ Master Mono 409001803 and observed that now this issue is not exists. We are not getting DLLs like System.Xml.dll and System.Security.dll in output dir with msbuild.

I am getting:
Imacs-iMac:~ imac$ cd Desktop/Fakta
Imacs-iMac:Fakta imac$ cd Fakta/
Imacs-iMac:Fakta imac$ ls-l src/Fakta.Tests/bin/Debug/
-bash: ls-l: command not found
Imacs-iMac:Fakta imac$ ls -l src/Fakta.Tests/bin/Debug/
total 18880
-rwx------  1 imac  staff    90624 Feb  1  2016 Aether.dll
-rwx------  1 imac  staff    97792 Feb  1  2016 Aether.pdb
-rwx------  1 imac  staff    15971 Feb  1  2016 Aether.xml
-rwx------  1 imac  staff      519 Jul  5  2016 App.config
-rwx------  1 imac  staff   350720 May 21  2016 Chiron.dll
-rwx------  1 imac  staff   407040 May 21  2016 Chiron.pdb
-rwx------  1 imac  staff      636 May 21  2016 Chiron.xml
-rwx------  1 imac  staff   239104 Sep 27  2015 FParsec.dll
-rwx------  1 imac  staff    88697 Sep 27  2015 FParsec.xml
-rwx------  1 imac  staff   109056 Sep 27  2015 FParsecCS.dll
-rwx------  1 imac  staff     6782 Sep 27  2015 FParsecCS.xml
-rw-r--r--  1 imac  staff     6144 Feb  8 13:01 Fakta.Tests.exe
-rwx------  1 imac  staff      519 Jul  5  2016 Fakta.Tests.exe.config
-rw-r--r--  1 imac  staff  3173888 Feb  8 13:01 Fakta.dll
-rw-r--r--  1 imac  staff    41136 Feb  8 13:01 Fakta.xml
-rwx------  1 imac  staff   610304 Apr 20  2016 FsCheck.dll
-rwx------  1 imac  staff   841216 Apr 20  2016 FsCheck.pdb
-rwx------  1 imac  staff    66770 Apr 20  2016 FsCheck.xml
-rwx------  1 imac  staff    12800 Jan 27  2016 Fuchu.FsCheck.dll
-rwx------  1 imac  staff    19968 Jan 27  2016 Fuchu.FsCheck.pdb
-rwx------  1 imac  staff      591 Jan 27  2016 Fuchu.FsCheck.xml
-rwx------  1 imac  staff   131072 Jan 27  2016 Fuchu.dll
-rwx------  1 imac  staff   202240 Jan 27  2016 Fuchu.pdb
-rwx------  1 imac  staff    13526 Jan 27  2016 Fuchu.xml
-rwx------  1 imac  staff    51200 Jun  1  2016 Hopac.Core.dll
-rwx------  1 imac  staff   224768 Jun  1  2016 Hopac.Core.pdb
-rwx------  1 imac  staff    21499 Jun  1  2016 Hopac.Core.xml
-rwx------  1 imac  staff   505856 Jun  1  2016 Hopac.dll
-rwx------  1 imac  staff   693760 Jun  1  2016 Hopac.pdb
-rwx------  1 imac  staff   126547 Jun  1  2016 Hopac.xml
-rwx------  1 imac  staff   251392 May 19  2016 HttpFs.dll
-rwx------  1 imac  staff    20054 May 19  2016 HttpFs.xml
-rwx------  1 imac  staff   401408 Apr 14  2016 NodaTime.dll
-rwx------  1 imac  staff   776335 Apr 14  2016 NodaTime.xml
Imacs-iMac:Fakta imac$ 

Hence closing this issue.
Comment 8 Kyle White 2017-02-08 19:03:12 UTC
Verified per Comment 7