Package Restore Failed Microsoft.WindowsAzure.Storage - azure-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.

Related

Cannot add Microsoft.AspNetCore.SpaServices.Extensions to project template created with Visual Studio 2019

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

How to include pre-release packages with MSBuild restore target

This question is specific to MSBuild 15.1+ (Visual Studio 2017) and to PackageReference, which is the new way Nuget is fully integrated within MSBuild.
In my continuous integration script, I've got something like:
MSBuild.exe /t:Restore MySolution.sln /p:RestoreConfigFile=NuGet.config
One of the csproj file contains:
<PackageReference Include="MyPackageA">
<Version>1.2.*</Version>
</PackageReference>
MyPackageA is an internal package and I would like nuget to resolve the reference to the latest version available, including pre-release version.
Let's take 2 examples:
Example #1
Packages available are:
MyPackageA version 1.2.7-dev1
MyPackageA version 1.2.7-dev2
MyPackageA version 1.2.7-dev3
MyPackageA version 1.2.8
I would like nuget to resolve the dependency and pick up MyPackageA version 1.2.8.
Example #2
Packages available are:
MyPackageA version 1.2.7-dev1
MyPackageA version 1.2.7-dev2
MyPackageA version 1.2.7-dev3
MyPackageA version 1.2.8
MyPackageA version 1.2.9-dev1
MyPackageA version 1.2.9-dev2
I would like nuget to resolve the dependency and pick up MyPackageA version 1.2.9-dev2.
However, it would only resolve to version 1.2.8 (the stable release) in both examples.
Is there a way to tell MSBuild or Nuget to include pre-release packages?
At the moment, prerelease versions cannot be used together with floating versions.
You can use
<PackageReference Include="mypk" Version="1.0.*" />
OR
<PackageReference Include="mypk" Version="1.0.1-*" />
But not 1.0.*-*.
See this GitHub issue where this feature request is tracked.
How to include pre-release packages with MSBuild restore target
AFAIK, there is no such option -IncludePrerelease for nuget restore, you can check the Options for restore command. And MSBuild restore also does not have this option, MSBuild restore target.
This option is used for nuget Install, Update.
As a test, I added the option -IncludePrerelease or PreRelease to the command line nuget restore, then I got the error message:
Unknown option: '-IncludePrerelease'
Besides, when we restore nuget package with nuget.exe restoe or MSBuild.exe /t:Restore, nuget will downloads and installs any packages missing from the packages folder based on the package list in the packages.config and PackageReference, the version information is indicated in the those file, like:
<package id="ExamplePackage" version="6.1.0" targetFramework="net45"/>
and
<PackageReference Include="ExamplePackage" Version="6.1" />
NuGet will download the corresponding version of the package, so we do not need give the option -IncludePrerelease.
Update:
I should have mentioned my reference includes a wildcard and I would
like that wildcard to resolve to the latest version, including a
pre-release version if it's the latest.
Indeed, this is a issue about restore pre-release packages for PackageReference:
https://github.com/NuGet/Home/issues/912
You can track this thread to get the latest status for this issue, and NuGet team already set this issue as pri 0, and try to resolve this issue ASAP.
Hope this helps.
The NuGet,version >5.6, floating version syntax allows for some pretty powerful version ranges, but it is likely that your scenario will be mostly satisfied by the following 3 floating versions:
<!-- Float everything! Latest version available including prerelease-->
<PackageReference Include="mypk" Version="*-*" />
<!-- Prefer latest 1.X version, include prerelease and stable -->
<PackageReference Include="mypk" Version="1.*-*" />
<!-- Prefer latest 1.0.X version, include prerelease and stable -->
<PackageReference Include="mypk" Version="1.0.*-*" />
Ref

An assembly specified in the application dependencies manifest (...) was not found

I upgraded Microsoft.AspNetCore from 2.0.3 to 2.0.5 and my WebAPI project, although running successfully locally, fails to start in production (IIS). Everything was fine in production until this upgrade. The error message produced in the log directory is as follows:
Error:
An assembly specified in the application dependencies manifest (MyProject.WebAPI.deps.json) was not found:
package: 'Microsoft.AspNetCore.Mvc.Abstractions', version: '2.0.2'
path: 'lib/netstandard2.0/Microsoft.AspNetCore.Mvc.Abstractions.dll'
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
aspnetcore-store-2.0.5.xml
Could someone explain to me the details of exactly what this means? I assume it's a version mismatch of sorts, but why is this occurring? I thought the latest stable releases of NuGet packages weren't supposed to have such issues.
I was able to resolve the issue by downgrading Microsoft.AspNetCore.All from 2.0.5 to 2.0.3, but would like to find a better solution to the issue so I can use the most up-to-date version of this package.
Development machines usually have the SDK installed but on production the runtime only.
Add the following to your .csproj file and publish again.
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
Sometimes this is related to the Startup Project, For example if the migration is a class library in Azure Functions project. You have to make sure when you run Add-Migration while the EF Library project is selected as Startup Project.
For me, the marked answer didn't solve the issue. My issue was when trying to Add-Migration
Add-Migration -Name initial-migration -Context Mysln.Data.MyDbContext -StartupProject Mysln -Project Mysln.Core
And the error was like this:
I solved it by downgrading all my Entityframework packages to 2.0.0 instead of the latest 2.2.0-preview one.
If you have more than one project in your solution like me:
and if you want to scaffold dbcontext in your "non startup" project (InstantOrder.Functions.Data in my case)
then you should add the -StartupProject parameter of the Scaffold-DbContext command like this -
Scaffold-DbContext "Server=..." -Project InstantOrder.Functions.Data -StartupProject InstantOrder.Functions.Data
I know this may be old, but just in case it can help some one else, this one worked for me:
Adding:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
To the PropertyGroup in the .csproj file.
To solve the first half of the error message, An assembly specified in the application dependencies manifest (…) was not found be sure to always use the publish output when deploying to a target sever.
For a self-contained application it can be found in
bin\Release\netcoreapp2.0\win81-x64\publish
or for framework-dependent deployments in
bin\Release\netcoreapp2.0\publish
The output in the directories above are meant to be used in development only, since they are specific to machine and user configuration built with.
Taken from a related answer.
2 cents: If you just take from the build folder, the dlls for the dependency aren't provided. If you publish the folder, they are. This was the fix for me.
I had this error however my solution was somewhat different from what was posted above. My problem was that I was deploying via a zip file and while building the zip file I wasn't including sub directories therefore required files were not being included.
So if you are publishing via a zip file make sure to include all sub folders while building the zip.
I got this error while running Scaffold-DbContext command on the Library project.
Solution:
Remove the Azure Function project from the solution, and then run this command.
After that, use add an existing project feature to add the Azure Function project again in the solution.
The correct .NET Core runtime was not installed on my PC. I had NETCore.App 2.1 and 2.2, but the project was targeted to 2.0.
dotnet --list-runtimes
I installed the correct runtime from the dot.net site and it resolved the issue.
In most case you get that error because there's misalignment of versions.
I changed the Microsoft.VisualStudio.Web.CodeGeneration.Design version, an it worked.
Before
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
After
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" />
This happened to me when I published my Lambda to AWS after renaming the project. I deleted both the obj and bin folders, rebuilt, republished and that fixed it.
I changed filters in Yaml.
Had projects called TestHelper etc...
Testrunner tried to run projects without tests, and the build was flagged as failed.
Added:
!**\*Helper*.*
To:
- task: DotNetCoreCLI#2
inputs:
command: 'test'
projects: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
!**\*TestPlatform*.dll
!**\*Testing*.*
!**\*TestHost*.*
!**\*Helper*.*

InvalidOperationException: Cannot find reference assembly 'System.AppContext.dll' file for package System.AppContext.Reference

I've created a new project using ASP.Net Core 2 project targeting .Net framework 4.7.1 and I see the following error on startup.
"InvalidOperationException: Cannot find reference assembly 'System.AppContext.dll' file for package System.AppContext.Reference".
How to resolve this?
Add reference to following Nuget Package to resolve this error.
Package:
Microsoft.AspNetCore.Mvc.Razor.ViewCompilation
If you read the documentation from Microsoft, the fix for this problem is adding the following package reference to your web project:
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" />

Missing nuget packages error while using msbuild from command line

I am working on a silverlight app. We are using nuget packages but we dont check in the packages and the packages should be restored while building. The solution compiles well in visual studio.
I am trying to add a compile task in command line using msbuild
Exec { C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe $slnFile /p:OutputPath=$outputPath /p:Configuration=Release /p:SolutionDir=$rootDir\Source\ /verbosity:minimal /nologo /m:4 } "Build Failed
Before doing this step, I'm doing a nuget restore explicitly.
Exec { C:\project\nuget.exe restore $solutionFile} "restore failed"
This step passes with a message "All packages listed in packages.config" are already installed.
But when the actual build step happens the build fails with the message
This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is \Source\.nuget\NuGet.targets.
I am doing a nuget restore explicitly and I have enabled
"Allow nuget to download missing packages" in visual studio and
"Enable nuget package restore" in solution level.
My nuget.config has "disableSourceControlIntegration" value="true"
I have seen similar issues in stackoverflow and I have tried all the above solutions that were suggested. I don't have a clue why it fails in spite of all these.
You do not need to do both the nuget.exe restore and have MSBuild use NuGet.targets to restore the NuGet packages. You should choose one or the other.
I suspect the problem in your case is that $rootDir is not defined and the SolutionDir property you are passing to MSBuild is:
\Source
In my project file I have:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
So if SolutionDir is \Source then the solution will fail to compile with the same error message.
In mine, the csproj file somehow had this:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
Removing it had solved the problem.