7

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.

Community
  • 1
  • 1
David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • This SO post addresses the same issue, even though that's not obvious from the title: http://stackoverflow.com/questions/17220615/where-can-i-download-the-net-4-5-multitargeting-pack-for-my-build-server – John Hart Aug 19 '15 at 20:28

1 Answers1

3

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.

dipdapdop
  • 126
  • 1
  • 10
KMoraz
  • 14,004
  • 3
  • 49
  • 82
  • Thanks for your answer. I just tried it and unfortunately it doesn't appear to work. I still get the exact same warning after adding /p:TargetFrameworkMoniker=".NETFramework,Version=v4.0" to the msbuild command line. :( – David Ebbo Apr 04 '12 at 17:45
  • Did you try passing other versions? or maybe you need references to `Profile=Client` – KMoraz Apr 04 '12 at 19:08
  • 'Client' by itself appears to be invalid ("FrameworkName cannot have less than two components or more than three components"). My guess is that this flag tells msbuild which target libraries to use assuming their SDK is installed. With no SDK on the machine, it may be that it doesn't do much. – David Ebbo Apr 04 '12 at 22:40
  • Hmmm, just found this page, and apparently it is not possible: http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/96b3ea2e-92ed-4483-bbfe-a4dda3231eb9. It says "Warnings with MSB prefix are thrown by MSBuild. Currently, we can't suppress MSBuild warnings" – David Ebbo Apr 04 '12 at 22:42
  • 1
    that thread is not about MSBuild 4.0 though. Above I meant `.NET Framework, Version=v4.0, Profile=Client` not the client itself. For this property suppressed the exact warning. – KMoraz Apr 04 '12 at 22:52
  • That doesn't work either. Have you actually seen a case were adding this flag made this specific warning go away? – David Ebbo Apr 05 '12 at 05:15