Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of msbuild warning MSB3644

When building a web project on a machine that doesn't have the SDK installed, you get this warning:

warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

Obviously, one way to get rid of the warning is to install the SDK. However, in this case, I'm simply looking to suppress this warning (which is mostly harmless) from the build output without changing the state of the machine in any other way.

I tried passing /p:NoWarn=3644 to msbuild (based on other posts like how can i suppress all compiler and code analysis warnings from msbuild at the command line?), but that had no effects.

like image 724
David Ebbo Avatar asked Apr 04 '12 06:04

David Ebbo


1 Answers

NoWarn applies to compilation warnings thrown by the Csc and Vbc tasks.

MSB* warnings are core MSBuild warnings. To suppress MSB3644 warning pass an explicit TargetFrameworkMoniker:

msbuild your.csproj /t:Rebuild /p:TargetFrameworkMoniker=".NETFramework,Version=v4.0"

The list of possible inputs can be found here.

v1.1.4322
v2.0.50727
Client
v4.0
v4.0.30319
.NET Framework, Version=v4.0, Profile=Client
.NET Framework, Version=v4.0
.NET Framework, Version=v4.0.1, Profile=Client
.NET Framework, Version=v4.0.1
.NET Framework, Version=v4.0.2, Profile=Client
.NET Framework, Version=v4.0.2
.NET Framework, Version=v4.0.3, Profile=Client
.NET Framework, Version=v4.0.3
.NET Framework, Version=v4.5

In MSBuild 4.5 there's a new flag - IgnoreVersionForFrameworkReferences which might come handy on these warnings.

like image 84
KMoraz Avatar answered Oct 24 '22 13:10

KMoraz