.net core package restore failed - asp.net

Package restore
Package restore failed in ASP.NET Core 1.1.
Note: I am targeting following in my project.
"frameworks": {
"net461": { }
},
Recently I upgraded my project from ASP.NET Core 1.0 to 1.1 and it worked fine on my old laptop until I switched the project to fresh new laptop, and installed visual studio 15. Here is the configuration of the VS 15.
I have also installed the required SDK as mentioned on this link
https://jeremylindsayni.wordpress.com/2016/11/20/upgrading-from-net-core-1-0-t0-1-1-with-visual-studio-2015/
Now my project.json file looks likes this.
And global.json looks like this.
{
"projects": [ "." ]
}
But as you can see the packages are not loading as expected. When I run dotnet restore from the package manager console I get something like this.
Any ideas ??

I fixed same issue when i add file
If you see this error with adding some code file for example Controller, View etc.
Than one of reasons is CodeGeneration package failed when you try to add some file.
add nuget package which is
Microsoft.VisualStudio.Web.CodeGeneration.Design

Related

VSTS build: Packages failed to restore - Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'

I'm getting
Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'.
in VSTS build using Hosted2017 build agent after I upgraded my aspnetcore app to netcoreapp2.0 and my libraries to use netstandard2.0.
Works fine locally.
I've edited my build definition to use .net core build task v2.* preview:
here is the build log:
Current agent version: '2.120.2'
Download all required tasks.
Downloading task: DotNetCoreCLI
Starting: Get Sources
Syncing repository: Liero/vyvojari-sk (GitHub)
...details ommited
HEAD is now at e448a25... Upgraded to .NET Core 2.0
Finishing: Get Sources
Starting: Restore
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version : 2.0.5
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
==============================================================================
SYSTEMVSSCONNECTION exists true
Downloading: https://dist.nuget.org/win-x86-commandline/v4.0.0/nuget.exe
Caching tool: NuGet 4.0.0 x64
Using version: 4.0.0
Found tool in cache: NuGet 4.0.0 x64
Saving NuGet.config to a temporary config file.
Can\'t find loc string for key: NGCommon_NoSourcesFoundInConfig
NGCommon_NoSourcesFoundInConfig d:\a\1\Nuget\tempNuGet_734.config
"C:\Program Files\dotnet\dotnet.exe" restore d:\a\1\s\src\CommandStack\CommandStack.csproj --configfile d:\a\1\Nuget\tempNuGet_734.config --verbosity Detailed
Restoring packages for d:\a\1\s\src\CommandStack\CommandStack.csproj...
C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'. [d:\a\1\s\src\CommandStack\CommandStack.csproj]
Generating MSBuild file d:\a\1\s\src\CommandStack\obj\CommandStack.csproj.nuget.g.props.
Generating MSBuild file d:\a\1\s\src\CommandStack\obj\CommandStack.csproj.nuget.g.targets.
Writing lock file to disk. Path: d:\a\1\s\src\CommandStack\obj\project.assets.json
Restore failed in 115.64 ms for d:\a\1\s\src\CommandStack\CommandStack.csproj.
Errors in d:\a\1\s\src\CommandStack\CommandStack.csproj
Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'.
NuGet Config files used:
d:\a\1\Nuget\tempNuGet_734.config
Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
Packages failed to restore
******************************************************************************
Finishing: Restore
******************************************************************************
and here is the source code: https://github.com/Liero/vyvojari-sk/tree/e448a25fb8c481704e9102aaaeb8b84b9aee7b02
Update 18/09/2017
Step 2 is no longer needed. I've left it in the solution though as it may still help some people. Thanks, #Liero for point this out.
Original Answer
I've just experienced this problem too and solved it by doing three things:
Use the .NET Core SDK(! - not runtime!) version 2.0.0:
Use the latest NuGet feed (4.3.0):
Restore your packages:
Update
It's worth mentioning here that you should specify where you get your NuGet packages from. Most applications will probably just use the NuGet.org feed, as per the screenshot (see small checkbox), but you may have your custom feeds specified in a NuGet.config file. In that case, tick 'Feeds in my NuGet.config' and then specify the path to that file.
To illustrate the order, this is my working queue:
I hope this helps you and anyone else who has come up against this problem. If you have any questions, let me know. :)
You should select Feed(s) I select here for Feeds to use option. If you leave Use packages from this VSTS/TFS feed empty, packages will be downloaded from https://dist.nuget.org/.
Else, if you want to use Feeds in my NuGet.config as Feeds to use, you should specify the path for your NuGet.config file.
I have received a similar error after generating a project using dotnet new angular which created a project relying on netcoreapp2.0. Inspection of project properties revealed that version 2.0 was not properly recognized (did not appear in the installed framework list).
Solution was to update Visual Studio 2017, as the minimum version required to support netcoreapp2.0 projects seems to be 15.3.1.
What worked for me was installing .NET Core SDK 2.0 and making the following changes:
in .csproj:
change
<TargetFramework>netcoreapp1.1.0</TargetFramework>
to
<TargetFramework>netcoreapp2.0</TargetFramework>
and in global.json:
"sdk": { "version": "1.1.0" }
to
"sdk": { "version": "2.0.0" }
I didn't know how to use Chris Paton' solution
Updating the Visual Studio 2017 to latest 15.4.1 version resolved the problem for me.

How to run ssis package in asp.net core application?

I have used Microsoft.SqlServer.Dts.Runtime to run package in ASP.NET MVC. However I need to run this in asp.net core. As we cannot add individual dll in asp.net core, I was wondering if anyone has idea if there is nuget package which would help.
Just to elaborate on how I resolved this issue. Below is the answer
To run SSIS package you need below DLLs in the code
Microsoft.SqlServer.ManagedDTS.dll
Microsoft.SqlServer.PipelineHost.dll
Microsoft.SqlServer.DTSRuntimeWrap.dll
Microsoft.SqlServer.DTSPipelineWrap.dll
It is easy to add DLLs in MVC projects, however in asp.net core it needs to be in form of a Nuget package.
So nuget package can be easily created using nuget package explorer. Below is the link
https://docs.nuget.org/create/using-a-gui-to-build-packages
In the nuget package explorer add a lib folder, inside that add a .net folder dnxcore50 and add the above DLLs. Click on tools analyse package and save the nuget
In the visual studio 2015 solution, you can refer local packages.
Tools - Nuget Package Manager - Package Manager Settings - Package source
add the local package path.
After which you will be able to add the nuget package using nuget package manager and select local package as source
If there is error in restoring package, add dnxcore to imports section and add "Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027" to dependencies in project.json
"dependencies": {
"Microsoft.AspNet.Hosting": "1.0.0-rc1-final",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027",
"SSISPackage": "1.0.0"
}
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8",
"dnxcore"
]
}
}
After which you will be able to use code to run SSIS package similar to MVC projects.
Application app = new Application();
Package package = null;
try
{
package = app.LoadPackage(#"C:\Files\Package.dtsx", null);
Variables vars = package.Variables;
vars["status"].Value = "ACTIVE";
DTSExecResult results = package.Execute();
}
catch
{
return false;
}
finally
{
package.Dispose();
package = null;
}
You can package the assembly into a nuget package, Create a Lib folder inside your solution to hold the nuget package, then, create a nuget.config file to set the package sources to include the Lib folder inside your solution.
The following links contains more details about creating nuget package and hosting it locally:
https://docs.nuget.org/create/creating-and-publishing-a-package
https://docs.nuget.org/create/hosting-your-own-nuget-feeds
https://docs.nuget.org/consume/nuget-config-file
Hope that helps
You may now reference the dlls ( one from each) directly in your .net core project from the below locations to run ssis packages now
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ManagedDTS
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.PipelineHost
C:\Windows\Microsoft.NET\assembly\GAC_64\Microsoft.SqlServer.DTSRuntimeWrap
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.DTSPipelineWrap
you no longer need to create a nuget package

Is it possible to add a reference to NetCore library from a NetCore app without using the same solution?

I have a netstandard1.6 Project "MyLibrary"
I have a netcoreapp1.0 Project "MyApplication"
I have to reference "MyLibrary" from "MyApplication", without having those on the same solution.
Is it possible? How?
It's really confusing how DNX RC1 jumped into what Asp .Net 5 is right now, I can't seem to get going with it, I've read several articles and no documentation answered those questions to me.
With .Net Core, there are two ways to reference dependencies:
Reference another project in the "solution", where the solution is specified by a global.json file.
For example, the relevant part of your project.json could look like this:
"dependencies": {
"MyLibrary": { "target": "project" }
}
Reference a NuGet package from a known package source. Package source can be either web-based (like nuget.org), or it can be a directory. You can configure known package sources either locally or globally using a nuget.config file.
Example project.json excerpt:
"dependencies": {
"MyLibrary": "1.0.0"
}
For you, this means you have two options:
Add the library project to your "solution" by including it in your global.json.
Produce a NuGet package from your library (you can use dotnet pack for that), place it into a package source (probably just a directory) and configure that package source in a nuget.config file.

Errors creating ASP.NET Core 1 application

I have VS2015 and I am attempting to create an ASP.NET Core 1.0 application.
I select the template and also leave the defaults (host in azure and identity security set to individual).
I enter the details for the Azure instance and then when the project loads in VS2015 it errors straight away against DNX 4.5.1 and DNX Core 5.0. I have tried package restore but no luck. in the project.json file I have:
{
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
#Adrien got me onto the right track. I used the Nuget command line to install the latest release for Newtonsoft.Json. It successfully installed and I could see the change to the version in the project.json file. However I still had the same error displaying. Although it had updated the main file, the project.lock.json file didn't get it's references updated at the same time. I had to close my project and re-open before the reference change took effect to the lock file.

How does kpm manage content folders in a NuGet package?

I'm running Visual Studio 15 Preview, and started a new project: ASP.NET Web Application > ASP.NET 5 Empty. I then opened project.json and modified it to add AngularJS.Core 1.3.4 as follows:
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta1",
"AngularJS.Core": "1.3.4" // I only added this line
},
I see the package downloaded and added to my packages folder, but the nupkg file has a content folder (with the actual *.js files I want added), but those files aren't being added to my project. There are no error messages or warnings of any kind (at least none via the package manager log).
I have also tried running kpm --verbose install ... and kpm --verbose restore via the command line, and I don't see anything useful for solving this.
I know I can manage this manually, but am I missing something? Is this a bug, or am doing this wrong, or are my expectations incorrect? I'm new to this ASP.NET vNext stuff, and this is my first time jumping into it.
It doesn't. KPM currently doesn't do anything with packages that contain content/powershell scripts/transforms etc.

Resources