Skip to content

A warning causes build to fail, but still says "0 Errors" #5100

@itsho

Description

@itsho

Steps to reproduce

Use the attached solution (.NET 4.0 Console app) - MsBuildComIssue_v1.zip

Or, create it manually:

  1. Create a .NET project (I'm using WPF) with reference to a specific COM object MSHTML- "00020430-0000-0000-c000-000000000046" version 2.0.

  2. make sure you are using a machine without Microsoft Office!

  3. use msbuild to build the project.

In the log you can see that it will use the following "csc" command:

C:\Program Files (x86)\Microsoft Visual Studio\<yourVersion>\MSBuild\<yourVersion>\Bin\Roslyn\csc.exe 
	/noconfig 
	/nowarn:1701,1702 
	/nostdlib+ 
	/errorreport:prompt 
	/warn:4 
	/define:TRACE 
	/highentropyva-
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.CSharp.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\PresentationCore.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\PresentationFramework.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.DataSetExtensions.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xaml.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll"
	/reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\WindowsBase.dll" 
	/debug:pdbonly 
	/filealign:512 
	/optimize+ 
	/out:obj\Release\myProject.dll 
	/ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" 
	/resource:obj\Release\myProject.g.resources 
	/target:library 
	/utf8output 
	/deterministic+ 
	yourFile.cs

Expected behavior

build should either fail or succeed - depending on if you have the COM object registered.

Actual behavior

C:...\Bin\Microsoft.Common.CurrentVersion.targets(2729,5): warning MSB3283: Cannot find wrapper assembly for type library "MSHTML". Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform must not be 64-bit. [C:\Proj.csproj]
Done executing task "ResolveComReference" -- FAILED

The build will fail with exit code 1!
but you'll still see "0 Error(s)"

Environment data

tested on both:
msbuild /version output:

Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.4.0.56107

And

Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
15.9.21.664

OS info:

Windows Server 2016 1607 14393.3443

Side note:

As I suspected it's an issue with the content of the GAC, here's a list of the content:
gacutil-list.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Area: LoggingArea: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.help wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.triaged

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions