How to solve Failed to add reference to 'Micro

2019-01-27 23:30发布

I got empty Class library project and want to install following NuGet as dependency:

nuget-bot.Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.12.0.31101

Installation fails with error:

Failed to add reference to 'Microsoft.WITDataStore'.

Other nugets, e.g. Entity Framework or Microsoft.TeamFoundation.Client I was able to install.

My Configuration

  • Windows 7 Enterprise
  • Visual Studio Enterprise 2015
  • NuGet Package Manager for Visual Studio 2015

Thanks.

3条回答
三岁会撩人
2楼-- · 2019-01-28 00:08

It looks like this is a mistake in the configuration of the NuGet package.

Microsoft.WITDataStore.dll is an unmanaged library that cannot be directly referenced by a .NET project, which is why the package installation fails.

The Microsoft.TeamFoundation.WorkItemTrackingClient.DataStoreLoader.dll is a .NET wrapper library allowing access to the unmanaged code in Microsoft.WITDataStore.dll. What should be happening is that the package should add the .NET library (DataStoreLoader.dll) as an assembly reference and add the unmanaged library (WITDataStore.dll) as a content-item configured to be copied into the bin\ directory on build. Instead, it's attempting to add them both as assembly references, which fails and is rolled back by NuGet.

I've used NuGet's "Contact Owner" feature to attempt to notify the publisher at Microsoft of the package's misconfiguration, but since it's been published by "nuget-bot", I don't know if that will accomplish anything. I'll update this answer if the package is updated to resolve the issue. The workaround I'm currently using is to:

  1. manually download the package, unzip it, and copy the unzipped folder into my solution's packages\ directory.
  2. Add a reference in my project to the copy of Microsoft.TeamFoundation.WorkItemTrackingClient.DataStoreLoader.dll in the unzipped package.
  3. Add the file WITDataStore.dll as an Existing File to my project, and mark it as "Copy Always" under "Properties". ("Copy if newer" will also work just fine)

  4. Add the line <package id="nuget-bot.Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader" version="12.0.31101" targetFramework="net452" /> to the packages.config file for my project.

This results in NuGet having a record of the package being installed, the DataStoreLoader.dll being referenced, and the WITDataStore.dll being copied into your bin\ folder whenever you build, so it can be used by wrapper library.

查看更多
Bombasti
3楼-- · 2019-01-28 00:17

Please use the official NuGet packages. I've written this blog post as a guide. I still hope to get the non-official packages taken down.

查看更多
再贱就再见
4楼-- · 2019-01-28 00:21

I have resolved this error by simply copied Microsoft.WITDataStore.dll in to Microsoft Team Foundation packages folder. You can copy this dll after downloading this package manually.

packages\Microsoft.TeamFoundation.11.0.0.0\lib\net20

Hope this helps you

查看更多
登录 后发表回答