Andrey Bushman
Andrey Bushman

Reputation: 12516

Why the NuGet packages can't be installed?

Windows 7 SP1 x64, Visual Studio 2017

I create a new ASP.NET Core MVC project on the base of Empty template:

enter image description here

Later I try to install the Microsoft.VisualStudio.Web.CodeGeneration.Tools and Microsoft.VisualStudio.Web.CodeGenerators.Mvc packages through NuGet Package Manager but they throws exception during installation and are rolled back:

enter image description here

How can I fix it?

UPD

If try to do the same through NuGet Console then I see more detailed exception info:

enter image description here

UPD2

Thanks to Leo-MSFT. His advice helped to me to install of Microsoft.VisualStudio.Web.CodeGenerators.Mvc package but I have the problem with installing the Microsoft.VisualStudio.Web.CodeGeneration.Tools package still:

enter image description here

Upvotes: 0

Views: 1397

Answers (1)

Leo Liu
Leo Liu

Reputation: 76996

Why the NuGet packages can't be installed?

That is because Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.0/1.1 (.NETCoreApp,Version=v1.0). Package Microsoft.Composition 1.0.27 supports: portable-net45+win8+wp8+wpa81. You will get this messages in the Output window.

To resolve this issue, you can use Visual Studio 2015 instead, if you still want to use Visual Studio 2017, you could add PackageTargetFallback to .csproj file like this:

<PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
  </PropertyGroup>

Then add those two packages by NuGet.

Update:

For the UPD2 question: You can install the package Microsoft.VisualStudio.Web.CodeGeneration.Tools by NuGet Package Manager UI rather than NuGet package Console. Because nuget team punted the work to support tools installs via the UI with the idea that tools will be installed by default with new projects or you can add the below lines manually to the csproj file in order to install the tool:

<ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
  </ItemGroup>

For more detail information, you can refer to the issue 4190.

Upvotes: 1

Related Questions