Today, I will show you how to create the debug and release EXE file type and fix errors on your projects.
With these two commands, you will create the EXE file type for debugging and releasing the project.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | C:\CSharpprojects\FreeRAM>dotnet publish -c Debug -r win10-x64 Microsoft (R) Build Engine version 16.11.3+5d7fe36cf for .NET Copyright (C) Microsoft Corporation. All rights reserved. Determining projects to restore... Restored C:\CSharpprojects\FreeRAM\FreeRAM.csproj (in 50.52 sec). FreeRAM -> C:\CSharpprojects\FreeRAM\bin\Debug\netcoreapp3.1\win10-x64\FreeRAM.dll FreeRAM -> C:\CSharpprojects\FreeRAM\bin\Debug\netcoreapp3.1\win10-x64\publish\ C:\CSharpprojects\FreeRAM>dotnet publish -c Release -r win10-x64 Microsoft (R) Build Engine version 16.11.3+5d7fe36cf for .NET Copyright (C) Microsoft Corporation. All rights reserved. Determining projects to restore... All projects are up-to-date for restore. FreeRAM -> C:\CSharpprojects\FreeRAM\bin\Release\netcoreapp3.1\win10-x64\FreeRAM.dll FreeRAM -> C:\CSharpprojects\FreeRAM\bin\Release\netcoreapp3.1\win10-x64\publish\ |
To fix errors on your project you can use this command:
1 2 3 | C:\CSharpprojects\FreeRAM>dotnet restore Determining projects to restore... Restored C:\CSharpprojects\FreeRAM\FreeRAM.csproj (in 789 ms). |
Sometimes the upgrade of the NuGet packages or dot net version can crash your project.
Because the cs file type has the source code these files can be renamed into new files in order to be preserved.
For example Program.cs can be renamed into Program.bak.
Delete the bin and obj folders and the csproj file project.
Try to create another new project and rename back the backup source code files.
Add the old packages, see the example of the FreeRAM project from my old tutorial:
1 | dotnet add package System.Management |
If you run again the project and you get errors about the: package … is not compatible with netcoreapp3.1 then you need to delete all files from : C:\Users\Your_User\.nuget\packages.
This is similar to the operation of clean NuGet caches.
The last step is to