.NET Core Web API 5.0 build errors - .net-5

Severity Code Description Project File Line Suppression State
Error NETSDK1005 Assets file 'D:\Working On\Gra\Gra\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v5.0'. Ensure that restore has run and that you have included 'netcoreapp5.0' in the TargetFrameworks for your project. Gra C:\Program Files\dotnet\sdk\5.0.100-preview.1.20155.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 234
I've just create ASP.NET Core Web Application, and then when I run, I it's show message errors!

In my publish profile the Target Framework was set to NET5.0.
Changed it to NET6.0 and the problem was gone.

Update to Nuget 5.8
Clear the local cache
error NETSDK1005: Assets file 'project.assets.json' ....
Try updating NuGet.exe to the 5.8.0 version or above:
nuget update -self
if you prefer to update the nuget version in Visual Studio, just follow this steps. Then, clear NuGet cache:
dotnet nuget locals all --clear
Download Nuget
found here

Delete the 'obj' folder and re-build the project.

You're using an extremely old .NET 5 preview. ASP.NET Core Preview 1 specifically had no new features, it was essentially a version number change. There's no netcoreapp5.0 framework target any more, it's net5.0.
The latest version is 5.0 RC1 which is feature-complete and supported in production. Install it and create a new project with, eg dotnet new webapp or dotnet new webapi etc.
This version is supported by the latest Visual Studio 2019 Preview version.

Related

Visual Studio for Mac trying to find .NET Full Framework in build properties

Visual Studio for Mac (Version 8.8.7 (build 18)) is unable to upgrade netcoreapp3.1 asp.net mvc project to .net5.0 target framework. It throws below error:
/usr/local/share/dotnet/sdk/3.1.405/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(5,5):
Error NETSDK1005: Assets file 'App.Mvc/project.assets.json' doesn't
have a target for '.NETFramework,Version=v5.0'. Ensure that restore
has run and that you have included 'net50' in the TargetFrameworks for
your project. (NETSDK1005) (App.Mvc)
It will create a net5.0 mvc project from scratch alright but upgrade fails with the error. I've also tried to move all the files over into a new net5.0 from my netcoreapp3.1 project and somehow it converts the new project to .net full framework again. There's no clear indication as to what's causing this issue.
Ok I figured it out. I had a global.json pointing to version 3.1.*. Had 5.0.102 and it worked.

How to change .Net Core 2.1 project to .Net Core 2.0 project

Having trouble converting my .Net Core 2.1 project to .Net Core 2.0. I changed the target build type in my project solution properties as well as target framework in my .csproj file. Visual Studio will not let me build this application because the project is still inherently .Net Core 2.1.
I've had a similar issue recently. Cleared my packages folder and vs cache. Restarted vs, and everthing did build fine.
I changed the target framework in my .csproj file and what did the trick for me was reinstalling older NuGet packages.
Got the same issue
Deleting the content of the "bin" folder did the trick

Visual Studio 15.8.0 Preview 2.0 - MVC - Core 2.1 - Adding SOAP as Connected Service - Version for package dotnet-svcutil could not be resolved

I am working with the following: Visual Studio 15.8.0 Preview 2.0, ASP.NET Web Application, with Target of .NET Core 2.1. I am trying to add a SOAP service as a Connected Service. (I had the same problem with VS 15.7.4, so I thought going to the preview version might find this issue fixed)
I chose Microsoft WCF Web Service Reference Provider.
When I try to add the SOAP service, I get:
Version for package dotnet-svcutil could not be resolved
...
I went the following route without success (mlacouture - mentioned changing nuget.config in directory svcutil_starter to fix the location of the svcutil package, then doing dotnet restore on the Nuget package. With this preview version of VS, the location of svcutil in nuget.config is already correct (C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ENTERPRISE\COMMON7\IDE\EXTENSIONS\MICROSOFT\WCF CONNECTED SERVICE\svcutil\dotnet-svcutil.1.0.0-preview-20406-879.nupkg).
I continue to still get:
C:\Program Files\dotnet\sdk\2.1.300\NuGet.targets(114,5): error : The local source 'C:\Users\medwa163\AppData\Local\Temp\WCFConnectedService\2018_Jun_22_08_01_15\svcutil_starter\dotnet-svcutil.1.0.0-preview-20406-879.nupkg' doesn't exist. [C:\Users\medwa163\AppData\Local\Temp\WCFConnectedService\2018_Jun_22_08_01_15\svcutil_starter\svcutil_starter.csproj]. It definitely does exist.
If I copy the package to the same directory at the Nuget.config, and change Nuget.config to point to it, I get the same error. Cleared the nuget cache and same error.
GitHub Info on Potential Workaround
...
Any insight into this would be greatly appreciated.
I was finally able to find a solution for this.
I temporarily changed the target of the project from .NET Core 2.1 to .NET Core 2.0. Then I was able to add the service.
After that, I changed the target back to .NET Core 2.1 and tested. I was able to call the service successfully.

.Net Core 1.1.0 NuGet packages fail to install in Visual Studio Mac

I'm playing around with a ASPNet.Core 1.1.0 application in Visual Studio Mac Preview and have problems updating/installing NuGet packages.
If I try to update eg. Microsoft.AspNetCore.Diagnostics from 1.0.0 to 1.1.0 it fails the download and removed the package completely. I then have to download and install the package for 1.0.0 again. Same goes for Microsoft.AspNetCore.Server.Kestrel.
Microsoft.EntityFrameworkCore I'm not able to install in any version.
Heres the exception output: https://gist.github.com/anonymous/52ceb28b8d9781835b226bcbe9d04d58
I know everything is right out of the oven, but was wondering if other people have experienced the same issues and know of a workaround/solution.
For everyone else having similar problems, here's a walk-through:
First install .NET Core 1.1.0: https://www.microsoft.com/net/core#macos
The official .NET Core 1.1.0 installer (as of when this is written) includes the .NET Core SDK 1.0.0 Preview 2.
You will need .NET Core SDK 1.0.0 Preview 3. Download it here: https://github.com/dotnet/core/blob/master/release-notes/preview3-download.md
Create a new project in Visual Studio Mac
Close the project
Open up project/src/myapp/myapp.csproj and change "netcoreapp1.0" to "netcoreapp1.1". Save and close the file.
<TargetFramework>netcoreapp1.1</TargetFramework>
Open your solution in Visual Studio Mac and compile it.
Now you will be able to update your NuGet packages to newest versions.
Should you run into problems, do a "dotnet restore" when standing in /project/src/myapp/
I reached out on Twitter and got a response from Mikayla Hutchinson, Xamarin PM at Microsoft. Check out the conversation on Twitter here.
certain NuGet packages fail to restore if they're not already in
your local cache - see https://developer.xamarin.com/releases/vs-mac/preview/vs-mac-preview1/#Known_Issues
as a workaround, you can use dotnet restore on the command-line,
which will restore and cache them
I hope this helps.
Try to change *.csproject file manually to
<TargetFramework>netcoreapp1.1</TargetFramework>
UPDATE
#egeek So, finally, I think I found some trick. I tried to add Swashbuckle Nuget package, but it failed. Then, when Visual Studio start to adding Swashbuckle, I click Forece Quit from Visual studio before the operation is complete. In *.csproj I see:
<PackageReference Include="Swashbuckle">
<Version>6.0.0-beta902</Version>
</PackageReference>
And when I again open Visual studio, click "Restore" on "Packages" folder.
Finally it not fail and added Swashbuckle correctly.
Try upgrading your nuget latest version for core 1.1 https://dist.nuget.org/index.html will resolve the issue.

Adding MOQ to a .NET 4.0 project is not possible

I want to add MOQ .net library to a .NET 4.0 project. I get an error message that I should convert the project to something smaller than 4.0. I need to use .NET 4.0 also because of other project dependencies.
How can I make MOQ work with a .NET 4.0 project in VS2010 ?
Make sure you have NuGet package manager installed (Tools/Extension Manager).
Right click on Solution Explorer/References, choose Manage NuGet Packages.
Type Moq in the search box.
Install and enjoy.
The latest version from Google Code (http://code.google.com/p/moq/), works in a .Net 4.0 project. I would just download the dll again.
Here is the download link: http://code.google.com/p/moq/downloads/detail?name=Moq.4.0.10827.Final.zip
The zip file at that location contains a .Net 4 folder. Use the dll : Moq.dll from the NET40 folder and everthing will work fine. Just do a normal Add Reference on the project.
I would check the version number and the Runtime veseion of the assembly you are trying to use. It should say:
Runtime Version: v4.0.20926
Version: 4.0.10827.0
For the sake of completeness, it may be worth pointing out that it is also possible to use the Visual Studio command line package manager tool:
1) Open the console in VS
View >> Other Windows >> Package Manager Console
2) Install Moq
Type Install-Package Moq at the prompt
Note: If your tests are in a separate project, make sure that you select that project in the project dropdown.
This will install the latest package available in NuGet, which should address your compatibility issue. See http://nuget.org/packages/moq.
Watch out that you're using .NET 4, rather than the .NET 4 Client Profile as your Target Framework. I had the same issue and that was the cause for me.

Resources