Ошибка nuget nu1202

Permalink

Cannot retrieve contributors at this time

title description author ms.author ms.date ms.topic ms.reviewer f1_keywords

NuGet Error NU1202

NU1202 error code

zhili1208

lzhi

06/25/2018

reference

anangaur

NU1202

NuGet Error NU1202

Package 'PackageId' 4.0.11 is not compatible with 'TargetFramework'. Package 'PackageId' 4.0.11 supports:
- 'TargetFrameworkA'
- 'TargetFrameworkB'
- 'TargetFrameworkC'

Issue

A dependency package doesn’t contain any assets compatible with the project.

Solution

Change the project’s target framework to one that the package supports.

I noticed a «v4.0» in the .sln.metaproj file. I haven’t been able to
figure out what to check for or how to debug this.

Some tips that may help for trouble-shooting and resolving the issue:

#1. I think the .sln.metaproj in solution folder and .csproj.metaproj in project folder should be excluded from Source Control. At least these files is not recommended to publish to Azure Devops Repos.

Check their content we can find something like <ProjectConfiguration Project="{xxx}" AbsolutePath="C:Usersxxxsourcerepos...>, it’s an absolute path in local machine. When using Hosted agent in Build Pipeline, these paths are invalid.

#2. Also, I checked the log of Nuget Restore task, and confirm the content of xx.xx.metaproj files won’t affect the nuget restore process. So I think your issue didn’t result from this.

#3 The NU1202 indicates the package is not compatible with current project. Check the log of Nuget Restore task you’ll see something like this:

enter image description here

The error message will tell us which project causes the issue. Open the xx.csproj file in Devops Repos to check its content. I assume the version of the project targets v4.0 or one of its targetFrameworks(multi-targeting) is v4.0. And if that project is a sdk-format project, you may need to use dotnet restore task to restore packages for that.

Update:

See here, nuget restore command won’t receive and recognize build configuration. So for this situation, nuget can’t access the propertyGroup whose conditions is $(Configuration.Contains('xxx')). Then it is equivalent to nuget restore xx.sln=>nuget restore one project whose TargetFrameworkVersion is empty.And then nuget will consider this project uses default 4.0. So the issue occurs.

Steps to reproduce:

1.Create a simple .net framework 4.7 project, add this into xx.csproj:

    <PackageReference Include="AppCenter.Analytics.Metrics">
      <Version>1.1.0</Version>
    </PackageReference>

2.Comment the <!--<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>-->

3.Save all and nuget restore xx.sln, same issue occurs:

enter image description here

Possible Workaround:

nuget restore won’t accept something like nuget restore xx.sln -property:Configuration=xxx like nuget pack command. So this issue will always occur unless we define the valid TargetFramework version in propertyGroup no matter which conditions. (I guess this is not what you want, but this issue cannot be avoided for this situation)

So I think a better choice is to use msbuild /t:restore instead of nuget restore. For VS2017 and above, msbuild has contained the restore option itself. And it works for those .net fx based projects that use PackageReference format.

So you can use VS build task with arguments /t:restore to restore the packages instead of using Nuget restore(this is not suitable for your custom csproj script).

enter image description here

When you use pwsh or powershell core (the newest version of powershell) you may face a problem regarding the compatibility with .NET 6.

Installing PowerShell on Windows – PowerShell | Microsoft Learn

PowerShell 7.3 installs to a new directory and runs side-by-side with Windows PowerShell 5.1. PowerShell 7.3 is an in-place upgrade that replaces PowerShell 7.0 and lower.

Error:

error NU1202: Package PowerShell 7.3.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0) / any. Package PowerShell 7.3.0 supports: net7.0 (.NETCoreApp,Version=v7.0) / any
The tool package could not be restored.
Tool ‘powershell’ failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the –version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

Solution:

In order to resolve the error you should install .NET 7.

Download .NET 7.0 (Linux, macOS, and Windows) (microsoft.com)

Студворк — интернет-сервис помощи студентам

Доброго времени суток.
При подключении пакетов EFCore.SQLServer и EFCore.Tools
как через NuGet так и через консоль возникает ошибка «NuGet NU1202»
подключаю пакеты к консольному приложению на Core.
Студия 19 года. Все компоненты для работы с Core , вроде как установлены

Текст ошибки :
«Серьезность Код Описание Проект Файл Строка Состояние подавления
Ошибка NU1202 Пакет Microsoft.EntityFrameworkCore.SqlServer 3.0.0 несовместим с netcoreapp2.1 (.NETCoreApp,Version=v2.1). Пакет Microsoft.EntityFrameworkCore.SqlServer 3.0.0 поддерживает: netstandard2.1 (.NETStandard,Version=v2.1) ConsoleApp1 C:UsersWin10ProsourcereposConsoleApp1ConsoleApp1ConsoleApp1.csproj 1
«

Как с этим бороться?
Заранее благодарен

Asked
3 years, 9 months ago

Viewed
172 times

Whenever I try to run my project I keep getting this NU1202 error, for one of the custom packages provided by my company. I’ve tried deleting the folder and recloning from remote, to no avail.

The odd thing is that it works just fine for other people in my team.

  • visual-studio
  • visual-studio-2017
  • nuget

asked Aug 27, 2019 at 20:36

Gene Parcellano's user avatar

Gene ParcellanoGene Parcellano

5,7714 gold badges36 silver badges43 bronze badges

1 Answer

answered Aug 27, 2019 at 20:36

Gene Parcellano's user avatar

Gene ParcellanoGene Parcellano

5,7714 gold badges36 silver badges43 bronze badges

1

  • Since you’re in a .net core proejct which use packageReference format, the installed packages are stored in the cache not in project directory, so you need to clean the cache to solve this issue. You can also use the option in vs.

    Aug 28, 2019 at 2:24

  • The Overflow Blog
  • Featured on Meta

Linked

Related

Hot Network Questions

  • Homotopy type of the geometric realization of a poset

  • Is there a word is the opposite of «Childless»? (Specifically for when trying to categorize an adult)

  • A witness (former gov’t agent) knows top secret USA information. Can a court compel them to reveal the informaton?

  • How can I join two bezier curves at a 90 degree angle?

  • Would it be possible to create a technology that allows telekinesis?

  • What is the shortest regex for the month of January in a handful of the world’s languages?

  • What’s the name of the book series about a woman who is almost immortal and who breeds like a mole rat?

  • Why did some stigmatized theonyms survive in English?

  • Can you aid and abet a crime against yourself?

  • Why and when would an attorney be handcuffed to their client?

  • Does the gravitational field of a hydrogen atom fluctuate depending on where the electron «is»?

  • Why might a civilisation of robots invent organic organisms like humans or cows?

  • Nonstandard game results

  • Does my Indonesian friend need to prepare the visa for her 8 year old son (US passport holder) to visit Slovakia and the Czech Republic?

  • Where did Lagrange write his technique of Resolvents for solving polynomial?

  • Could you grapple a creature with the Thri-Kreen’s Secondary Arms?

  • Garage door suddenly really heavy, opener gives up

  • Why did my papers get repeatedly put on the last day and the last session of a conference?

  • Can I drink black tea that’s 13 years past its best by date?

  • Is PhD the only way to study glaciers?

  • What were the Minbari plans if they hadn’t surrendered at the battle of the line?

  • ESTA & travel within the United States

  • Render text in a slanted ASCII-art font

  • Did anybody use PCBs as macro-scale mask-ROMS?

more hot questions

Question feed

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Понравилась статья? Поделить с друзьями:
  • Ошибка ntwdblib dll
  • Ошибка ntvdm exe на windows 7
  • Ошибка ntvdm cpu has encountered an illegal instruction
  • Ошибка no response grandstream
  • Ошибка no response from gameranger server