Posts in category “Tips”

Clear nuget cache

cat ~/bin/clear-nuget-cache
nuget locals all -clear

Reference

Fix `Set-ItemProperty: Cannot find drive. A drive with the name 'IIS' does not exist.` issue

Background We still have quite a few projects that depends windows platform. I met Set-ItemProperty: Cannot find drive. A drive with the name 'IIS' does not exist. issue when I was running a powershell script, and I couldn't find an answer until I asked my colleague Matthew.

The ANSWER

Powershell 7 is supposed to support all platforms, so it removed those windows specific features.You should use Powershell for windows instead.

Yes, this solved the issue. Thanks!

git stash -S # stash staging changes only

git-stash-s.png

Don't change the inode when editing a file with Vim

I keep my config files on github, and I use hard-link for most of the config files. It's convenient, as I can check the new changes easily and submit some of the changes when necessary. However, the default behavior of vim troubles me. It always changed the inode when I save the config file!

tldr; the solution is: put the following line in your .vimrc

set backupcopy=yes

PS Though this way fixed Vim's behavior, I sadly found that git pull will change the config file's inode as well. So there is actually no feasible solution. I have abandoned this hard link approach. If you have better solutions to maintain all your config files in one repository, please let me know!

How to delete all bin/obj folders in a complex solution in GitBash

Sometimes we need to delete all the bin/obj folders in a solution to resolve issues in Rider or Visual Studio. I assume you already have your preferred method for this task, but I would like to share my approach here in case someone else is unaware of how to do it in GitBash or MSYS terminal:

#!/bin/bash

set -e

# Find and display directories to be deleted
find . \( -iname "bin" -o -iname "obj" \) -type d -print

# Prompt user for confirmation
read -p "The above folders are going to be deleted, are you sure? [Y/N]: " -n 1 -r
echo    # Move to a new line

# Delete directories if confirmed
if [[ $REPLY =~ ^[Yy]$ ]]; then
    find . \( -iname "bin" -o -iname "obj" \) -type d -exec rm -rfv {} +
    echo "Done"
else
    echo "No"
    exit 1
fi