Cannot add Microsoft.AspNetCore.SpaServices.Extensions to project template created with Visual Studio 2019 - asp.net-core

Trying to create a new project in Visual Studio 2019 using ASP.NET core + React + Redux template
I am new to VS2019 + ASP.NET, just trying to get a basic template going, but IDE is showing this under error list:
Severity Code Description Project File Line Suppression State
Error NU1101 Unable to find package Microsoft.AspNetCore.SpaServices.Extensions. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages <projectName> <projectPath> 1
.csproj shows this dependency:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.14" />
</ItemGroup>
I tried installing the dependency using the command line, as described on https://www.nuget.org/packages/Microsoft.AspNetCore.SpaServices.Extensions/3.1.14
dotnet add package Microsoft.AspNetCore.SpaServices.Extensions --version 3.1.14
But now I get this error:
error: Package 'Microsoft.AspNetCore.SpaServices.Extensions' is incompatible with 'all' frameworks in project
It seems awfully strange to me that the IDE's template doesn't work out of the box, nor can I install what appears to be the dependency required for the template. Has anyone seen this problem before?

I had the same problem with VS2019 and .Net5, the solution I found is this, go to
Tools > NuGet Package Manager > Package Manager Settings
then select Package Sources and click on the option to add a new source, use this url for the source: https://api.nuget.org/v3/index.json
you can find more info here https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio#package-sources

Related

Package Restore Failed Microsoft.WindowsAzure.Storage

I switched my 4.8 project to SDK format and am trying to restore the Nuget packages I need.
I can see that it is available in Nuget
However when I try to install it I get
NU1101 Unable to find package Microsoft.WindowsAzure.Storage
If I have the following in my project
<PackageReference Include="Microsoft.WindowsAzure.Storage" Version="9.3.3.0" />
Then when I build I get an error.
No packages exist with this id in source(s) nuget.org
[Update]
Now I see that the package version is deprecated
However if I try installing Azure.Storage.Blobs 12.11.0 I get
Error NU1605 Detected package downgrade: Azure.Core from 1.22.0 to
1.6.0. Reference the package directly from the project to select a different version.
The following works.
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3.0" />
When I right clicked the error in my source code VS2022 gave me the option of downloading from Nuget.

NuGet.targets error : '.', hexadecimal value 0x00, is an invalid character after upgrade to .Net Core 2.1.1

after upgrade to .Net Core 2.1.1 I got this error:
C:\Program Files\dotnet\sdk\2.1.301\NuGet.targets(114,5): error : An error
occurred while retrieving package metadata for 'System.IO.4.3.0' from source
'C:\Program Files\dotnet\sdk\NuGetFallbackFolder'.
C:\Program Files\dotnet\sdk\2.1.301\NuGet.targets(114,5): error : '.',
hexadecimal value 0x00, is an invalid character. Line 1, position 1.
not able to solve it using
nuget.exe locals -clear global-packages
nuget.exe locals -clear packages-cache
nuget.exe locals -clear http-cache
or
nuget.exe locals -clear all
thanks for any help
In my case it was simple, I just did the following:
In Visual Studio, click: TOOLS > NUGET PACKAGE MANAGER > PACKAGE MANAGER SETTINGS
Select Option NUGET PACKAGE MANAGER > GENERAL
In General, click on button CLEAR ALL NUGET CACHE(S) await a few seconds
After this , close all windows and go to TOOLS > NUGET PACKAGE MANAGER > PACKAGE MANAGER CONSOLE
type dotnet restore
done =)
There is a simple solution. Delete the file AppData\Roaming\NuGet\NuGet.config and then run the visual studio it can create the new file of NuGet.config
So I had this issue when ever I used to clone a new repo and my IDE tried to restore the nuget packages first, it would refuse to work without nuget cache being cleard. The below steps helped me fix this after some "investigation".
Delete the nuget config file from (C:\Users<UserName>\AppData\Roaming\NuGet)
In my case the issue was with internal nuget URL. There was some issue with VS IDE unable to communicate with the internal nuget store which had changed from http to https.
Close all instances of VS 2019 and try again.
Once the new internal nuget source was replaced with new url, the issue seemed to have been fixed.
I am running VS 2019 v 16.10.4 #Win 10
I've tried pretty much everything:
Deleted /obj and /bin folders
Cleared NuGet cache
Updated Visual Studio to latest version
Restarted PC
Created a new project and verified that builds, however when adding additional NuGet packages and tried to restore them, got the same issue
Tried some other stuff that I don't recall, however it didn't help
What actually resolved this issue for me was to delete the C:\Program Files\dotnet\sdk\NugetFallbackFolder\ and then run dotnet restore in any of my projects that were failing to build (all of them, which were using NuGet) and then subsequent dotnet build worked ok!
It seems like that folder should be safe to delete (Could I remove or move the folder NuGetFallbackFolder?), however I got a few errors after this with package manager, etc, which I worked around by re-creating an empty C:\Program Files\dotnet\sdk\NugetFallbackFolder\ and it all worked fine after that.
Hope this helps somebody in the same situation! :)

MSBuild Error after upgrading TeamFoundation dlls to 2017

So, we were using 2013 TFS dlls in our projects (namely TeamFoundation.Client, TeamFoundation.VersionControl.Client, and TeamFoundation.Common). I recently upgraded the project to use 2017 versions of the above mentioned dlls (We have VS2017). I am getting them from the below folder.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer
After upgrading, when I build my solution, I get the following error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.NETFramework.targets(56,5): warning : Resolved file has a bad image, no metadata, or is otherwise inaccessible. The system cannot find the path specified. (Exception from HRESULT: 0x80070003)
I am not familiar with MSBuild so not sure how to proceed.
The error takes me to the following line in the MSBuild code:
GetDependsOnNETStandard Condition="'$(_RunGetDependsOnNETStandard)' == 'true'"
References="#(_CandidateNETStandardReferences)">
<Output TaskParameter="DependsOnNETStandard" PropertyName="DependsOnNETStandard" />
</GetDependsOnNETStandard>
There is an outstanding issue with Visual Studio 2017 and DependsOnNETStandard that should hopefully be resolved in 15.8
I just encountered the same problem today when upgrading a project that was originally created VS 2015 and upgraded to VS 2017.
It looks like the upgrade of the projects misses a few elements in the XML that it needs.
If you edit the csproj files of the effected projects and add
<DependsOnNETStandard>false</DependsOnNETStandard>
to the top PropertyGroup like so:
<PropertyGroup>
...
<DependsOnNETStandard>false</DependsOnNETStandard>
</PropertyGroup>
It should resolve the issue. It did for me.
Details of the issue and discussion around it can be found at:
https://github.com/dotnet/sdk/issues/1544
According to your error log info, seems you are trying to build locally through Visual Studio or MsBuild command not TFS build.
Suggest you to use the latest version of dlls, Microsoft.TeamFoundationServer.Client and also upgrade your Visual Studio 2017 to latest version. For The system cannot find the path specified. issue try to
Clean All Projects.
Unload All Projects
Reload All Projects.
ReBuild Solution
Another way is :
Close the solution
Delete bin folder
Delete all obj folders
Open solution and build
If all of above still not work, suggest you add a more detail log and sample code for troubleshooting.

Visual Studio Team Services Continuous Integration: NuGet Restore Task Failed

I am using Continuous Integration feature in Team Services (was Visual Studio Online). My build definition targets a specific project in a solution (not the whole solution), which is ClientUI MVC website.
The solution contains three projects:
ClientUI
AdminUI
Client Services
The Build Definition for ClientUI Project:
Repository:
Nuget Installer Step:
I have tried different params but not working.
Visual Studio Build
Before trying to target the a single project, my build definition was targeting the whole solution with the following parameters:
NuGet Installer -> Path to Solution: **\*.sln
Visual Studio Build -> Solution: **\*.sln ; MSBuild Arguments: /p:outdir=$(build.artifactstagingdirectory)
It was working. However now, it generates this error in the Nugget Restore Task:
2016-04-22T21:07:00.6716725Z Set workingFolder to default: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\tasks\NuGetInstaller\0.1.25
2016-04-22T21:07:00.8163908Z Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\tasks\NuGetInstaller\0.1.25\NuGetInstaller.ps1
2016-04-22T21:07:01.5283529Z ##[error]Cannot find path 'C:\a\1\s\packages.config' because it does not exist.
2016-04-22T21:07:01.5439897Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.98.1\agent\worker\tools\NuGet.exe restore "C:\a\1\s\packages.config" -NonInteractive
2016-04-22T21:07:03.0441507Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2016-04-22T21:07:03.0597010Z ##[error]Cannot determine the packages folder to restore NuGet packages. Please specify either -PackagesDirectory or -SolutionDirectory.
2016-04-22T21:07:03.0909881Z ##[error]Unexpected exit code 1 returned from tool NuGet.exe
Try setting "Installation type" to "Install" for "Nuget Installer" task since you are using "packages.config" to install the packages.
For anyone curious, the source of the error about "Please specify either -PackagesDirectory or -SolutionDirectory" is that the build process is trying to issue a command similar to this:
C:\hostedtoolcache\windows\NuGet\4.4.1\x64\nuget.exe restore D:\a\1\s\MyProject\packages.config -PackagesDirectory packages -Verbosity Detailed -NonInteractive
The below screenshots should help if you want to build a project (rather than the solution) and your nuget "packages" folder is at the solution-level.
Additionally, you may need to specify this as the "MSBuild Argument" in the build task of your project: /p:SolutionDir="/"
I had the same thing sorted it out by changing the mapping - go to Repository tab, I had my mapping to another directory which means the nuget installer could not execute.

TEAMBUILD: error MSB4057: The target "GetXapOutputFile" does not exist in the project

I'm getting this error trying to run my Build thru TeamBuild in TeamExplorer on Visual Studio 2008.
On the Build Machine I installed VS SP1, Team Explorer, Silverlight 3 tools, and RIA Services.
I can compile no problem with Visual Studio on my machine and directly on the Build Machine. But I still cant compile on thru TeamBuild because it "says" I'm missing GetXapOutputFile target.
I checked C:\Program Files\MSBuild\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.Common.targets file and it does have the GetXapOutputFile target:
<!--
============================================================
GetXapOutputFile
This stand-alone target returns the name of the built xap file.It
only makes sense to call this after a build
============================================================
-->
<Target
Name="GetXapOutputFile"
DependsOnTargets="_CreateSLProperties"
Outputs="$(XapOutputFile)"
/>
Any idea what I might be missing?
Hi I was trying a command line build and had same issue, this solved it for me:
Properties menu of 'xxx.Web' project, 'Silverlight Application' tab, remove the current item and add it again. After that, when building..., the error will go away. But I don't know why it is.
Found here: http://connect.microsoft.com/VisualStudio/feedback/details/698689/error-msb4057-the-target-getxapoutputfile-does-not-exist-in-the-project