7

在未安装 SDK 的机器上构建 Web 项目时,您会收到以下警告:

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.

我尝试将 /p:NoWarn=3644 传递给 msbuild(基于其他帖子,例如如何在命令行中抑制来自 msbuild 的所有编译器和代码分析警告?),但这没有任何效果。

4

1 回答 1

3

NoWarnCsc适用于andVbc任务引发的编译警告。

MSB* 警告是核心 MSBuild 警告。要抑制 MSB3644 警告,请通过显式TargetFrameworkMoniker

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

可以在此处找到可能的输入列表。

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

在 MSBuild 4.5 中有一个新标志 -IgnoreVersionForFrameworkReferences可能会在这些警告中派上用场。

于 2012-04-04T07:39:24.007 回答