#dotnet – .Net Core Uninstall Tool !

Buy Me A Coffee

Hi !

I’ll hold my drone series to basically repost an amazing news for today:

Announcing the .NET Core Uninstall Tool 1.0!

This is amazing! Mostly because .Net Core versions are a “not-happy experience” to manage. If you work with them a lot, you probably find yourself going to “Add and Remove Programs” and spending from 5 minutes to 3 hours, manually unistalling all the non-required versions.

So, we have a new tool that will allow us to to this, but with an amazing set of commands. And, it works for Windows and Mac !

Let’s take a look. In example, to check my currently installed sdks, I can run a command that we already knows

dotnet --list-sdks

and the result is this one

So cool! And there are several very useful commands to see dependencies, SDKs required by Visual Studio and more (see references). I like the WhatIf version, so in example the following command

dotnet-core-uninstall whatif --all-below 2.2.301 --sdk

Shows the result of a dry run of removing all .NET Core SDKs below the version 2.2.301:

Again, check the documentation for all the possible scenarios. And, as I said, so cool !

Happy coding!

Greetings

El Bruno

References

#RaspberryPi – How to solve #dotnet core not recognized after reboot

Buy Me A Coffee

Hi!

So, after writing my posts on how to install dotnet core 3.1 on a Raspberry Pi 4, I found that after I reboot my device, the dotnet command stop working. When I run dotnet from bash I get the following message

~bash: dotnet: command not found

dotnet command not found

The problem, is that the export steps of the installation process were lost after the reboot. And, as reminder of what is the export command.

Linux export command is use to set export attribute for shell variables on Linux system. The Linux export command is one of bash shell built in command.

In order to fix this, we can add the commands into our [~/.bashrc] file. First we need to edit our file with the command

sudo nano ~/.bashrc

And add the lines

export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet
export PATH="$PATH:/home/pi/.dotnet/tools"
raspberry pi 4 edit bashrc to add dotnet core wrapper

Now we need to reload the [~/.bashrc] file with the command

source ~/.bashrc
dotnet command working after reload bash file

And that’s it ! if the command is not recognized, just reload the bashrc file.

Happy coding!

Greetings @ Burlington

El Bruno

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#HowTo – Grant permissions to a folder after #Git clone, to perform #dotnet restore on a #RaspberryPi #dotnetcore

Buy Me A Coffee

Hi !

Quick post today, to leave this as a public note. And, disclaimer, I’m not a Linux expert, just a normal user; I’m sure there are plenty of better ways to do this. Any advice will be appreciated.

Context: I’m working with Git and .Net Core 3.1. Just cloned a repository and ready to run my 2 favourite commands

dotnet restore
dotnet run

However, I found this error

raspberry pi dotnet restore access denied error
/home/pi/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Access to the path '/<path>.csproj.nuget.dgspec.json' is denied. [/<path>..csproj] 
/home/pi/dotnet/sdk/3.1.100/NuGet.targets(123,5): error :   Permission denied

I’m running dotnet under the user pi, and I haven’t found a way to automatically grant permissions to new folders for this user. So everytime I clone a repo I need to grant permissions with the command.

# sudo chmod -R 757 '<path>'
sudo chmod -R 757 '/home/pi/srcebgit/testsGit/20191227MLNet/myMLApp/consumeModelApp'

And now, it’s working

raspberry pi dotnet restore working after grant user permissions

Of course, I still need to deal with other permissions issues because this project has some copy files actions on the build. Now I know the way!

raspberry pi dotnet restore working error on run

Happy coding!

Greetings @ Burlington

El Bruno

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

#VS2019 – How to fix the [obj\project.assets.json’ not found] when building a #NetCore project

Buy Me A Coffee

Hi!

Quick post today. This one is to save me 30 minutes of internet search next time I face this error.

Context:

New .Net Core Console App.

When I build the console app for the 1st time I got this error.

  • Error: NETSDK1004
  • Assets file ‘<Path> \EventConsoleApp01\obj\project.assets.json’ not found.
  • Run a NuGet package restore to generate this file.
  • C:\Program Files\dotnet\sdk\3.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets
visual studio 2019 new dotnet core console error on 1st build, cant find assets json.jpg

It’s a very silly error. However, if you are old school, the standard methods to fix this won’t work.

So the right way to fix this is to open the NuGet Package Manager Console [Tools // Nuget Package Manager / Package Manager Console] and type the command

dotnet restore
visual studio 2019 dotnet restore on nuget package manager console.jpg

Then rebuild the project, and that’s it! The new build will restore all the package, and also install everything necessary for a console app to run

visual studio 2019 project after dotnet restore.jpg

Happy coding!

Greetings @ Toronto

El Bruno

#Windows10 – Cleaning some disk space, Windows SDK and #dotnetcore installs

Buy Me A Coffee

Hi!

I’m very careful with my disk space, however my C: drive in Windows 10 started to claim about low space. I got 3 disks on my machine, 2 SSDs and a regular one; and I always check to install all my software on my D: drive. So, that’s why running low space on C: was shocking.

So, I did a small check on the apps and contents using a lot of disk and I found 2 main sources

  • Windows 10 SDKs
  • DotNet Core SDKs and Runtimes

Every time a new version of Windows 10 is released, and I build a Windows 10 App, I get a new Windows SDK. Each one is around 2GBs, I got almost 20, so make your numbers.

Windows 10 Settings App and Features Apps sizes

Note: There is a cool feature to find usage space of installed apps by this, out of the box in Windows Settings.

The second one was related to .Net Core. I had a lot of versions installed, and every time I get a new update on Visual Studio 2019, it seems that I’m updating also my .Net Core SDKs. Right now, I only care about .Net Core 3, so it was time to uninstall all the others.

The official documentation ” How to remove the .NET Core Runtime and SDK” (see references) wasn’t very helpful. However, it was a good source to learn more about dotnet command, specially this one:

C:\> dotnet --list-sdks

This command list all the installed SDKs, and with a little of PowerShell scripting I manage to uninstall almost everything. Once I started this path, I also realize that the

$app.Uninstall()

command was not working, so a little search pointed me into an old article from Scott Hanselman, where he did a similar script to remove old .Net Core versions (see references).

The final script is

You can also get the ps1 file directly from GitHub here https://github.com/elbruno/Blog/tree/master/20191016%20Uninstall%20NetCore%20Versions

And a warning, the script will list all the installed dotnet sdks

And then, when the uninstall process start, we will require to confirm each uninstall action. Not very user friendly, but it get the work done!

Final advice is to repair the .Net Core 3 version, just in case something is missing.

Happy coding!

Greetings @ Burlington

El Bruno

References