NuGet restore during first asp.net vNext project - nuget

Today I installed ASP.NET 5 on windows and begun creating my first application in Visual Studio 2015.
When the project loads I get an error: "Package restore failed", specifically the following error:
Restore failed Det gick inte att hitta en del av s�kv�gen C:\Users\h\.dnx\packages\Microsoft.Win32.Primitives\4.0.0\Microsoft.Win32.Primitives.4.0.0.nupkg.sha512. NuGet Config files used:
C:\Users\h\AppData\Roaming\NuGet\nuget.config
C:\Users\h\documents\visual studio 2015\Projects\NextTest\nuget.config
Feeds used:
https://api.nuget.org/v3-flatcontainer/
C:\Program Files (x86)\Microsoft Web Tools\DNU
When I look for the missing file I find the following path missing:
C:\Users\h\.dnx\packages\Microsoft.Win32.Primitives\4.0.0\Microsoft.Win32.Primitives.4.0.0.nupkg.sha512
But this one exists, note the extra 0 in the version:
C:\Users\h\.dnx\packages\Microsoft.Win32.Primitives\4.0.0.0\Microsoft.Win32.Primitives.4.0.0.0.nupkg.sha512
How would I go about to solve this?
I've tried to search through the project files but no mention of neither Primitives nor verion 4.0.0.
The "Solution DNX SDK version" is 1.0.0-beta8, (beta5 was also available but not selected).

Delete C:\Users\h.dnx\packages folder and try running "dnu restore" command.

Related

There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'ios-arm64'

I was using VS Enterprise 17.3 preview 1 but my trial was expiring so I download and installed VS Community 17.3 preview 1. I open my MAUI project and build and I get this error;
There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'maccatalyst-x64
I assume I must've missed something in the installation so I go back but all the relevant components are installed
I double check with the Enterprise installation and they match. I then go back to opening the project in VS Enterprise and now I get the same error there too!?
I've tried deleting bin/obj folders cleaning and rebuilding;
I've tried adding this to the .csproj
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>
I've tried changing the TargetFrameworks from this:
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
To this (and a few other combinations):
<TargetFrameworks>net6.0-android;</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
So I'm now stuck unable to build :( help pls
Turns out I had an error in a blazor file that the compiler wasn't referencing. The 'no runtime pack' error was a red herring and unrelated to the actual error.

How to resolve the following error shown while trying to build the code for Azure DevOps on Visual Studio 2022 on Windows Server 2019

##[error]C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1217,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at...
my solution was to upgrade any project targeting .Net Framework 4.5 to 4.7.2 and then building on Visual Studio 2019 instead of 2022, same Win Server 2019
I am also having this issue. Here is my (unsuccessful) progress in trying to solve it
I am also having this issue in Visual Studio 2022 Community after switching all of my solution's projects from various versions of .NET Framework to now all targeting ".NET Framework 4.8".
My error (almost identical to OP's):
C:\Program Files\dotnet\sdk\6.0.101\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v2.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\Users\MyUsername\source\repos\MyRepo1\Source\Libs\MyLibs\MyLibProject\MyLibProject.csproj]
This error mentions column 5 of line 1217 of file C:\Program Files\dotnet\sdk\6.0.101\Microsoft.Common.CurrentVersion.targets, this leads to the part <GetReferenceAssemblyPaths of the following:
<Target
Name="GetReferenceAssemblyPaths"
DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn);GetFrameworkPaths">
...
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
RootPath="$(TargetFrameworkRootPath)"
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
...
</Target>
I understand that the parts like $(TargetFrameworkMoniker) are variables. To determine what these evaluate to, I go into Visual Studio, open the csproj file, go to "Build Events > Pre-build event command line" and type echo "TargetFrameworkMoniker" = "$(TargetFrameworkMoniker)". Then I save & build the project, ignore the errors and instead go to the window "Output" to see what these variable evaluate to. I do this for each of the variables. Below is the same code from above, but the variables are now what they actually evaluate to (for me):
<Target
Name="GetReferenceAssemblyPaths"
DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn);GetFrameworkPaths">
...
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'.NETFramework,Version=v4.8' != '' and ('' == '' or '' == '')"
TargetFrameworkMoniker=".NETFramework,Version=v4.8"
RootPath=""
TargetFrameworkFallbackSearchPaths=""
BypassFrameworkInstallChecks=""
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'' == ''"/>
</GetReferenceAssemblyPaths>
...
</Target>
I don't see anything that suggests anything other than ".NET Framework 4.8", so I am now unsure how to proceed.
I got this issue resolved by downgrading from Visual Studio 2022 to Visual Studio 2014. I uninstalled Visual Studio 2022 and installed Visual Studio 2014, and the rest fell in place. My installation is now up and running.
Changing from
vmImage: 'windows-latest'
to
vmImage: 'windows-2019'
worked for me. It used to work earlier because 2019 was latest, now the latest is 2022 and there is issue with that.
https://github.com/actions/runner-images/issues/5055

Cordova app for Windows, NuGet fails to get correct version of System.Collections.Specialized

I'm tearing my hair out trying to build a windows app using Cordova. The build error I'm getting is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(377, 5):
error : The package System.Collections.Specialized with version 4.0.0
could not be found in C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\.
Run a NuGet package restore to download the package.
[C:\cygwin64\home\Owner\src\apps\mytestapp-
gen\platforms\windows\CordovaApp.Windows10.jsproj]
In visual studio, I attempt to add the version of the package to the project and I get the following error:
Severity Code Description Project File Line Suppression State
Error Could not install package 'System.Collections.Specialized
4.0.0'. You are trying to install this package into a project that targets
'native,Version=v0.0', but the package does not contain any assembly
references or content files that are compatible with that framework. For
more information, contact the package author.
Can anyone advise how to resolve this?
I've looked at this very old question How can I make my managed NuGet package support C++/CLI projects? but I can't find anything (particually from the VS2017 era) that helps
May be, this helps others to solve the issue:
My Visual Studio 2017 installation must obviously have been damaged when removing the Visual Studio 2015 installation from that same machine. After I performed a repair of Visual Studio 2017 via Visual Studio Installer the isuue disappeared.

Dotnet restore not working

dotnet Version: 1.1.0 (global.json)
NuGet Version : 4.4.1.4656
VS2017 v15.5.2 (as Administrator)
.NET Core 1.1
The solution I am trying to build
Update I:
I just changed the project to run under target framework .NET Core v2.0 & sdk version 2.1.3 and I only get these kind of errors:
Severity Code Description Project File Line Suppression State
Error NU1202 Package Microsoft.Extensions.FileProviders.Physical 1.1.0
is not compatible with netcoreapp2.0 (.NETCoreApp,Version=v2.0).
Package Microsoft.Extensions.FileProviders.Physical 1.1.0 does not
support any target
frameworks. AspNetCoreExample C:\Users\Admin\Source\Repos\Examples\src\AspNetCoreExample\AspNetCoreExample.csproj 1
Update II:
While the following solves the current issue, i am not sure if it solves the root cause for this issue.
Delete the global nuget.config file %AppData%/Nuget/Nuget.config.
I fixed this issue by doing the following:
I migrated the project to .net core 2.0 and changed the global.json to point to sdk 2.1.3.
Removed all references in AspNetCoreExample manually and added the latest version for all of them.
Issues with target framework 1.1
When doing a restore from the solution in VS 2017:
When doing the restore from cmd (dotnet restore)
Running dotnet restore in Package Manager Console
NuGet.targets(103,5): error : Access to the path 'System.Runtime.dll'
is denied
.NET Core SDKs installed:
.NET Host
Now when opening the solution I get:
Comparing the log entries you pasted to their AppVeyor build,
https://ci.appveyor.com/project/Autofac/examples
Your machine's NuGet configuration seems to be broken. Analyze that and fix the issues.
You should add this code to your .csproj file
<RuntimeFramework>2.0.3</RuntimeFramework>
This worked for me.

##[error]The given path's format is not supported

I am trying to setup build definition in TFS 2015 .WHen i try to setup build ,it's failing and giving below error:
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
12. 2017-03-31T13:59:36.1211815Z ##[error]The given path's format is not supported.
13. 2017-03-31T13:59:36.1368100Z ##[error]Unexpected exit code 1 returned from tool NuGet.exe
I tried selecting restore nuget package as well as everything I could do but I am not getting which path's format is being fetched. Please help me.
This error is similar to Nuget 3.4+ can not restore some packages fails with "The given path's format is not supported"
First, please check nuget.config and make sure nuget can find packages from your sources. Besides if you are using Nuget 3.4.x, give a try with version 3.5.0-rtm-1829