Skip to content

Commit 1675206

Browse files
nd-netAndreas Hartl
and
Andreas Hartl
authored
feat: adds a set-dotnet-env script for xonsh (#20)
Co-authored-by: Andreas Hartl <git@nd-com.net>
1 parent d478063 commit 1675206

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ For fish shell, instead use:
7272

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

75+
For xonsh shell, instead use:
76+
77+
`source ~/.asdf/plugins/dotnet/set-dotnet-env.xsh`
78+
7579
# Contributing
7680

7781
Contributions of any kind welcome! See the [contributing guide](contributing.md).

set-dotnet-env.xsh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env xonsh
2+
3+
def asdf_update_dotnet_home() -> None:
4+
dotnet_path=$(asdf which dotnet).rstrip('\n')
5+
if dotnet_path:
6+
$DOTNET_ROOT=$(dirname $(realpath @(dotnet_path))).rstrip('\n')
7+
dotnet_version=$(dotnet --version).rstrip('\n')
8+
$MSBuildSDKsPath=$DOTNET_ROOT + "/sdk/" + dotnet_version + "/Sdks"
9+
10+
@events.on_chdir
11+
def update_dotnet_home_on_chdir(olddir, newdir, **kw) -> None:
12+
asdf_update_dotnet_home()
13+
14+
@events.on_post_init
15+
def update_dotnet_home_on_post_init() -> None:
16+
asdf_update_dotnet_home()

0 commit comments

Comments
 (0)