Errors creating ASP.NET Core 1 application - asp.net

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.

Related

How do I get the .NET Core runtime version of a self-contained deployment (SCD) application?

I publish my .NET Core app using dotnet publish -r linux-x64, so it is self-contained and .NET Core runtime is not installed on the server where it runs. It's being built using .NET Core 2.1.something - I think. How do I get the exact version to know for sure? Ideally I'd like to get this at runtime, so the application itself can report what runtime it's running on, but even if there is some SDK tool that reports it (like dotnet get-runtime-version My.Assembly.Dll) that's better than nothing.
When the application is published, it will generate My.Assembly.deps.json and this contains the information about the included runtime. Look for the version of Microsoft.NETCore.App that is referenced.
Example (trimmed only to the relevant properties):
{
"targets": {
".NETCoreApp,Version=v2.2/win-x86": {
"My.Assembly/1.0.0": {
"dependencies": {
"Microsoft.NETCore.App": "2.2.4"
},
"runtime": {
"My.Assembly.dll": {}
}
}
}
}
}
deps.json is further documented in Runtime Configuration Files as part of the .NET Core CLI spec, although it doesn't directly define the relationship to the runtime version.

.net core package restore failed

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

Could not find System.Runtime 4.1.0.0 when running ASP.NET web application

I've created a Portable Class Library with the following projects.json
{
"supports": {},
"dependencies": {
"Microsoft.CSharp": "4.0.1",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
"System.Runtime.Serialization.Primitives": "4.1.1",
"System.Runtime": "4.1.0"
},
"frameworks": {
"net451": {},
"netstandard1.5": {}
}
}
However, when referencing this from an ASP.NET application (not ASP.NET Core), I get the following runtime exception:
Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
If I reference it from a console application it runs without issues.
Any ideas?
Edit
Found a solution here: https://stackoverflow.com/a/37639003/691045
As mentioned in the update one solution to this problem is to package up the PCL as a nuget package. This however goes contrary to what one is trying to do when one targets .Net Standard with a PCL. Also the package solution becomes cumbersome to debug.
To me it appears as a bug with Net Core Tools Preview when crossing the csproj to xproj boundary. To evidence this if one install the package via nuget:
Install-Package System.Runtime
The System.Runtime looks correct in the project.json as "System.Runtime": "4.1.0". Looking at the references, one will see that the version is listed as System.Runtime (4.0.20). Also the actual bin has absolutely reference to the actual dll.
Simply copying the .Net 4.6.2 dll from the nuget cache into the bin solves the problem. This allows for direct references without packaging up your PCL.
Hopefully when we hit Net Standard 2.0 and the tooling matures a bit more this type of thing will be a thing of the past.
UPDATE: If you use the latest .Net Core release (1.1) and binaries this is fixed. The tool preview is still on 1.0.1 so you have to make sure you install the binaries for 1.1.
I was getting a similar warning from ReSharper while running unit tests:
The solution that worked for me was to run this in the Package Manager console:
Update-Package System.Runtime -Reinstall
What I observed is that before running the above command, the reference in the affected project was to System.Runtime v 4.0.20.0, but post execution, it changed to 4.1.1.0
I was experiencing this issue after upgrade the .NET framework from 4.6.2 to 4.7, after digging around on several forums and the internet for a while and trying a lot, I found a solution and consits in two steps:
I deleted all Dependent Assambly and update all nugets UPDATE-PACKAGE -projectName -reinstall.
After the first step, I checked every missing assambly that throw me an exception in runtime and realize that in some cases the framework has a dll in our local machine that has nothing to do with the nuget then I deleted all local's dll references and install it from the nuget. After cleaning from the missing dll taking them from the Nuget my project run without any issue.
Hope that help you.

Trying to set environment in VSCode launch.json on OS X

I'm building an ASP.Net Core RC2 MVC Application on OS X
I don't seem to be able to set my environment for development
I think I should be able to add within my launch.json file:
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
I've tried adding it within the "name": ".NET Core Launch (web)" section. But "env" is not recognised. The version of the launch.json file is set as "version": "0.2.0", The error i get shown in the editor is Property env is not allowed
Has anyone got this working on OS X?
Thanks.
The issue is with OmniSharp for VS Code, as found at Issue #172 on their repo.
If you install their most recent preview release, the environment variable will work as intended. Download the VSIX file, and open it using the Open File dialog in VS Code. When the official release comes out, it will still suggest extension updates as per normal.

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