1

Windows 7安装后,我.NET 4.5.2创建了一个针对 .NET 4.5.2 的新 ClassLibrary 项目。

我想通过启动Visual Studio 2013metrics.exe附带的FxCop位于c:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\.

一切正常。

然后我 nuget System.Collections.Immutable v1.1.37

我可以在引用中看到只有 System.Collections.Immutable 被引用,因为找到了其他依赖项(System.Runtime,System.CollectionsSystem.Diagnotics.Debug)(我想在c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\

我创建了一个创建虚拟 ImmutableArray 的虚拟方法var foo = new List<int>().ToImmutableArray();

一切都可以编译并且工作得很好。

我重新启动了指标计算。

我有以下错误:

metrics.exe /f:c:\dev\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll /o:toto.xml

错误:CA0055:无法加载文件:'c:\dev\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll'。

如果我对程序集执行相同的命令,System.Immutable.Collections则会出现以下错误:

计算文件 'c:\dev\ClassLibrary1\ClassLibrary1\bin\Debug\System.Collections.Immutable.dll' 的指标。找不到框架程序集“System.Runtime,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”。

现在,如果我复制System.Runtime位于c:\Windows\Microsoft.NET\Framework\v4.0.30319\输出目录中的文件,计算代码指标就ClassLibrary1.dll可以正常工作。但是,如果我复制其中的版本c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\,如果再次失败。

在 Web 应用程序中使用 Immutable 调试另一个库时,我可以在“加载的模块”中看到以下内容:

System.Runtime.dll C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll 是 否 跳过加载符号。544 4.06.1055.0 06/11/2015 03:49 000007FED10D0000-000007FED10D9000 [15760] w3wp.exe [4] /LM/W3SVC/2/ROOT/WebSite-2-131026947404276669

所有这一切让我认为 System.Collections.Immutable 使用了 System.Runtime 的版本c:\Windows\Microsoft.NET\Framework\v4.0.30319\

所以我想,“让我们添加一个对该程序集的显式引用。” 如果这样做,我会收到以下编译错误:

错误 CS1703:已导入具有等效标识的多个程序集:“c:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll”和“C:\Program Files (x86)\Reference Assemblies\Microsoft\ Framework.NETFramework\v4.5.2\Facades\System.Runtime.dll'。删除重复引用之一。

某处有问题,我无法确定。

我使用/ignoreinvalidtargetsfor解决了这个错误metrics.exe

有人知道真正的错误吗?

(我还尝试以 .NET Framework 4 为目标,并c:\Windows\Microsoft.NET\Framework\v4.0.30319\使用 CopyLocal = true 添加对所有依赖程序集的引用。尽管有以下警告,它仍然有效:

某些 NuGet 包是使用与当前目标框架不同的目标框架安装的,可能需要重新安装。访问http://docs.nuget.org/docs/workflows/reinstalling-packages了解更多信息。受影响的包:System.Collections、System.Collections.Immutable、System.Diagnostics.Debug、System.Globalization、System.Linq、System.Resources.ResourceManager、System.Runtime、System.Runtime.Extensions、System.Threading

)

谢谢。

4

0 回答 0