I attempted to create a new project using the yeoman generator, however when i then move into the folder to restore the dependencies I encounter an error.
I start in an empty directory then execute the following
yo aspnetcore-spa (select the Aurelia framework and .csproj project type)
dotnet restore
I get the following error
warn : The folder '<path>/projFolder' does not contain a project to restore.
.NET Core projects using csproj require at least .NET Core CLI Preview 3. Double check which version is being used by running dotnet --info. If it is 1.0.0-preview2 or 1.0.0-preview2-1, it does not support csproj.
At the time of writing, the SDKs that support csproj are not listed on the main .NET Core download page. The latest is the RC3 release of .NET Core CLI.
https://github.com/dotnet/core/blob/master/release-notes/rc3-download.md
If you have installed the new SDK and dotnet --info still shows an older version, check for a global.json file in the current directory or any parent directories and make sure the "sdk" setting has the right version. The aspnetcore-spa generated creates a global.json file with SDK 1.0.0-preview3-004056, which is not the latest SDK.
Just update your dotnet-core-framework-version.
I fixed this by doing:
apt-get remove dotnet-dev-1.0.0-preview2-1-003177
apt-get install dotnet-dev-1.0.0-rc4-004771
Then:
dotnet restore
worked.
Then, you must reinstall the framework 1.1.1:
apt-get install dotnet-sharedframework-microsoft.netcore.app-1.1.1
(currently [22.03.2017], Visual Studio 2017 will use .NET Core 1.1.1 when it does publish)
Also, when you run a published project, it's
dotnet yourdll.dll
and not
dotnet run yourdll.dll
Edit:
Just one day later, and you might want to
apt-get install dotnet-dev-1.0.1
instead of rc4. You can then skip sharedframework, as sharedframework 1.1.1 gets installed automatically with dotnet-dev-1.0.1.
Related
I have a .NET Core Web Application with target framework .netcoreapp2.0.
If i publish my application via Visual Studio (folder profile) I get a different Newtonsoft.Json.dll then with the command dotnet publish --configuration Release --output D:/publish/Frontend /property:PublishWithAspNetCoreTargetManifest=false
VS publish version:
dotnet publish version:
The created file AutomaticConfirmationWebfrontend.deps.json has always this dependency:
"runtime": {
"lib/netstandard1.3/Newtonsoft.Json.dll": {
"assemblyVersion": "10.0.0.0",
"fileVersion": "10.0.1.20720"
}
}
This results in a problem for my CI/CD process where I publish my app with the command dotnet publish. If I open the website I get an error message that the assembly Newtonsoft.JSON 10.0.0.0 could not be found. If i copy manually the DLL with version 10.0.0.0 to the application folder it works! Debugging my application locally works also fine!
I have no Newtonsoft NuGet package installed. I think I am using the built in package from .NET Core.
In my Startup.cs I have the following line of code:
services.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
I need this for lowercase JSON objects. I have imported this namespace:
using Newtonsoft.Json.Serialization
Anybody an idea what I'm doing wrong or how to fix this?
I did 3 steps:
Upgraded to netcoreapp3.1
Removed all nuget packages from C:\Users\******\.nuget\packages
Installed the latest MSBuild installer
Late answer but it may help someone in future. Within the solution some other (other project) NuGet package also depending Newtonsoft.Json.dll. Check all your NuGet package dependencies especially Testing projects which may be mapped with low version Newtonsoft.Json.dll. (Refer below pic).
If that is the problem, then you can map .csproj file in your publish command like below,
dotnet publish src/myproject.csproj --configuration Release --output D:/publish/Frontend /property:PublishWithAspNetCoreTargetManifest=false
I updated a project from netcoreapp2.2 to netcoreapp3.0 and use Preview8 SDK as well as Microsoft.EntityFrameworkCore.SqlServer, tools, and design.
I can build and run my projects locally just find (VS 2019). But when I try to deploy with Azure DevOps, the Nuget restore gives this error:
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview8.19405.11 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview8.19405.11 supports: netstandard2.1 (.NETStandard,Version=v2.1)
Every reference to an EntityFrameworkCore package will result in that error.
I'm setting the .Net Core SDK in the pipeline to Preview8 via a global.json.
I have a NuGet tool installer task, bringing in the latest version, and a Nuget Restore task command running against my solution.
My problem was that I was using the Nuget Restore. Changing it to dotnet restore made the trick.
This problem is caused by an obsolete version of NuGet agent.
Use NuGet Install Tool task (a.k.a. Use NuGet) and setup the agent to the v5.x.
This is a low profile solution.
EDIT: Yay, I have enough rep to comment now.
It turns out the easier fix is to updatethe NuGet package version to the latest (5.3.0) in the "Use NuGet" task.
Not enough rep to comment on Fernando's response but it worked for me.
Edit the pipeline's Agent tasks:
add .NET Core, Display name: dotnet restore, Command: restore
set up other properties pretty much the same as the existing NuGet Restore
remove NuGet restore
Pipeline Nuget restore failing on .Net Core 3.0 Preview 8 project (NU1202)
If you are using the host agent, you should make sure you have install the netcoreapp3.0 on the agent. You could use the task Use .NET Core to install it:
Note check the option Include Preview Versions.
Note: Since netcoreapp3.0 supported by Visual Studio 2019, so, you need to make sure your agent is Hosted Windows 2019 with VS2019.
Hope this helps.
Where does dotnet core look for a nuget executable when running restore commands?
Is there a separate executable, or are the nuget functions built directly into the cli tools?
If I already have a nuget executable on my path, can dotnet be configured to use this?
NuGet is no longer an executable that runs for a restore operation, it has become an integrated part of the build tooling and the dotnet CLI.
NuGet operations have been turned into MSBuild tasks which are run during a build. This task would then load some NuGet libraries as needed. There are other tasks that use some NuGet components as well - such as the Pack target or some tasks used to determine framework compatibility (because NuGet knows which net* / netcoreapp* / netstandard* "frameworks" are compatible with another).
The dotnet CLI also uses some library functions of NuGet to execute commands such as dotnet add package or the dotnet nuget commands.
So instead of a single nuget.exe, you will find some NuGet related DLL files inside the SDK's directory and various components used during the build or command line operations will use functionality of these.
This also means that you can't easily replace them with any nuget.exe you have on your PATH.
Recently, I created an asp.net core project using Visual Studio Code on Windows and pushed it to GitHub. When I cloned the repo from GitHub and attempted to do a dotnet restore on the project on Ubuntu, an error message stating there was no project.json file was returned. Can anyone point me to a resource that will show me how to properly restore a .net core project from a Linux machine? Thanks!
So it seems like on each of your machines you are running different versions of the .net core SDK.
A big caveat with what you are trying to do. Are you trying to use Project Rider from Jetbrains on Linux? This only works with project.json (As of the time of this post) so be wary of that.
Now there are two ways to do this. If you are wanting the very latest on Linux and don't care about using Rider, then you can go here : https://github.com/dotnet/core/blob/master/release-notes/download-archive.md and download the latest release for both Linux and Windows, install on both and you should be good to go.
If you do care about using Rider or you aren't ready to be strapped in for the wild ride of the latest release. Then you can do the following.
Find what version of the SDK you have on linux by typing into a terminal the following :
dotnet --version
This will spit out what version you have on linux. Go here and download the same version for windows and install it on your windows machine (https://github.com/dotnet/core/blob/master/release-notes/download-archive.md).
Now BEFORE you create a project, create a solution folder and create a file in it called global.json. Inside that put the following :
"sdk": {
"version": "1.0.0-preview2-003131"
}
Where the SDK version matches what you got from your linux terminal. Now create a folder for your project inside the solution folder. Run "dotnet new -t web" or a similar command to create your project. It will inspect the SDK version of the global.json and create a project with the tooling that matches. You should then be able to shift this project around any machine that has the same SDK installed, even if it also has the latest SDK's also.
If you do not create the global.json, it defaults to the latest version (Atleast on Windows).
Read a bit more about it here : http://dotnetcoretutorials.com/2017/02/17/developing-two-versions-net-core-sdk-side-side/
I tried to create a simple .net core using commandline
dotnew new
in a certain folder called netcoreExample and I could see that there are two files created which are program.cs and project.json. Then I add Microsoft.EntityFrameworkCore to dependencies entry in project.json
When I try to run the command
dotnet restore
it shows the package is restores successfully. However, when I inspect the folder where I run dotnet restore from, I didn't see the "packages" folder which is usually created when with the old C# projects running Nuget restore.
I wonder where the dotnet restore output all of the dependencies to.
On Windows by default its %userprofile%\.nuget\packages. I wish dotnet restore -verbosity <verbosity-level> printed out where it was restoring to.
On other OSes its like <HOME-environment-variable-location>/.nuget/packages