Skip to content

Commit

Permalink
feat: adds a set-dotnet-env script for xonsh (#20)
Browse files Browse the repository at this point in the history
Co-authored-by: Andreas Hartl <git@nd-com.net>
  • Loading branch information
nd-net and Andreas Hartl committed Feb 6, 2024
1 parent d478063 commit 1675206
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ For fish shell, instead use:

`source ~/.asdf/plugins/dotnet/set-dotnet-env.fish`

For xonsh shell, instead use:

`source ~/.asdf/plugins/dotnet/set-dotnet-env.xsh`

# Contributing

Contributions of any kind welcome! See the [contributing guide](contributing.md).
Expand Down
16 changes: 16 additions & 0 deletions set-dotnet-env.xsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env xonsh

def asdf_update_dotnet_home() -> None:
dotnet_path=$(asdf which dotnet).rstrip('\n')
if dotnet_path:
$DOTNET_ROOT=$(dirname $(realpath @(dotnet_path))).rstrip('\n')
dotnet_version=$(dotnet --version).rstrip('\n')
$MSBuildSDKsPath=$DOTNET_ROOT + "/sdk/" + dotnet_version + "/Sdks"

@events.on_chdir
def update_dotnet_home_on_chdir(olddir, newdir, **kw) -> None:
asdf_update_dotnet_home()

@events.on_post_init
def update_dotnet_home_on_post_init() -> None:
asdf_update_dotnet_home()

0 comments on commit 1675206

Please sign in to comment.