what is major difference between dotnet publish and dotnet pack

dotnet pack – Produces a NuGet package of your code. That is the key difference – this will enable to publish to http://nuget.org, or to a nuget server that can be pulled down by other developers, or even for use with Octopus Deploy. dotnet publish – Produces a .NET framework-dependent or self-contained application. Keyword is … Read more

How to generate controller using dotnetcore command line

This is the new way since mid 2018 You have to install dotnet-aspnet-codegenerator. This is now done globally and not through a Nuget package: PowerShell: dotnet tool install –global dotnet-aspnet-codegenerator Then this is how you create a REST-Controller from an existing EF Model in PowerShell: dotnet-aspnet-codegenerator -p “C:\MyProject\MyProject.csproj” controller -name MyDemoModelController -api -m My.Namespace.Models.MyDemoModel -dc … Read more

run single *.cs script from command line

I found another solution on Scott Hanselman’s blog: https://www.hanselman.com/blog/CAndNETCoreScriptingWithTheDotnetscriptGlobalTool.aspx It relies on a .NET CLI tool called dotnet-script, you can find its repository below: https://github.com/filipw/dotnet-script To use, it, first install it using dotnet tool install -g dotnet-script Then you can run dotnet script and use it as a REPL or run dotnet script file.csx to … Read more

Could not load file or assembly ‘System.Runtime, Version=7.0.0.0…’ – After installing .NET Core 7 ‘dotnet watch run’ not working

According to the Microsoft document, the SDK uses the latest installed version and this is an expected behavior: The .NET CLI must choose an SDK version for every dotnet command. It uses the latest SDK installed on the machine by default, even if the project targets an earlier version of the .NET runtime. So, it … Read more

EF Core Error – No project was found. Change the current working directory or use the –project option

sometimes you need to change the current directory in console/terminal eg: PM> cd E:\Projects\CrossTest\ PM> dotnet ef migrations add InitialMigration and Align your package versions. Either use preview1 packages or preview2. Mix of those are not supported.