0

I'm building a build step to generate code metrics using the metrics.exe tool into our build pipeline. When running metrics.exe /f:MyApp.Web.dll /o:results.xml I get the following error.

Calculating metrics for file 'C:\Code\a\MyApp.Web\MyApp.Web.dll'.
error : CA0058 : The referenced assembly 'Microsoft.Owin.Security.Cookies, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be found. This assembly is required for analysis and was referenced by: C:\Code\a\SteelAccount.Web\Microsoft.AspNet.Identity.Owin.dll.

My packages.config references <package id="Microsoft.Owin.Security.Cookies" version="3.0.0" targetFramework="net45" /> and so I can understand why the error is occurring. There is no version 2.1 of the cookies assembly.

When I generate code metrics from Visual Studio it overcomes this problem somehow. Anyone know how?

Naeem Sarfraz
  • 7,360
  • 5
  • 37
  • 63

1 Answers1

1

When it runs it over a solution it includes all the referenced DLL's then filters out any that aren't part of your solutions projects. So if you used this command it should include the referenced DLLs:

metrics.exe /f:drive:\solutiondirectory*.dll /o:results.xml /acm:None

Edit: I ran Metrics.exe through .Net Reflector and it turns out that there is a switch for the compare mode that allows your example to succeed. Valid values for the "/acm:" switch are:

  • None
  • StrongNameIgnoringVersion
  • StrongName
Joe Swan
  • 200
  • 5
  • See the githib repo for an example, though references not as complex as actual project. I'll see if I can add more to it. https://github.com/naeemsarfraz/CodeMetricsProblemExample – Naeem Sarfraz Jul 09 '16 at 17:01
  • The switch `/acm:None` did it. Didn't think to use reflector, +1 – Naeem Sarfraz Jul 10 '16 at 06:01