Skip to content

Commit db81f33

Browse files
committed
add dotnet scenario
1 parent 7ead49a commit db81f33

File tree

5 files changed

+97
-0
lines changed

5 files changed

+97
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter()]
4+
[switch]
5+
$ForceUpdate
6+
)
7+
8+
# make shure all folders exsists
9+
mkdir "./bin" -Force;
10+
mkdir "./bin/downloads" -Force;
11+
mkdir "./bin/startup" -Force;
12+
mkdir "./bin/scripts" -Force;
13+
mkdir "./bin/dev" -Force;
14+
15+
16+
Copy-Item ..\..\src\scripts\install-vscode.ps1 ./bin\startup\install-vscode.ps1
17+
Copy-Item ..\..\src\scripts\install-dotnet.ps1 ./bin\startup\install-dotnet.ps1
18+
Copy-Item ..\..\src\scripts\update-dotnet.ps1 ./bin\scripts\update-dotnet.ps1
19+
Copy-Item ..\..\src\scripts\update-vscode.ps1 ./bin\scripts\update-vscode.ps1
20+
Copy-Item ./startup.cmd ./bin\startup\startup.cmd
21+
22+
# update all dependencies
23+
./bin/scripts/update-dotnet.ps1 @PSBoundParameters;
24+
./bin/scripts/update-vscode.ps1 @PSBoundParameters;
25+
26+
27+
# rewrite the paths in the sandbox.wsb
28+
$wsbXML = Get-Content ./sandbox.wsb -Raw;
29+
$wsbXML = $wsbXML.Replace('$(currentPath)', "$($PWD.Path)\bin");
30+
$wsbXML > ./bin/sandbox.wsb;
31+
32+
# start sandbox
33+
./bin/sandbox.wsb;

scenarios/csharp/sandbox.wsb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Configuration>
2+
<VGpu>Enabled</VGpu>
3+
<Networking>Enabled</Networking>
4+
<MappedFolders>
5+
<MappedFolder>
6+
<HostFolder>$(currentPath)\downloads</HostFolder>
7+
<ReadOnly>true</ReadOnly>
8+
</MappedFolder>
9+
<MappedFolder>
10+
<HostFolder>$(currentPath)\startup</HostFolder>
11+
<ReadOnly>true</ReadOnly>
12+
</MappedFolder>
13+
<MappedFolder>
14+
<HostFolder>$(currentPath)\dev</HostFolder>
15+
<ReadOnly>false</ReadOnly>
16+
</MappedFolder>
17+
</MappedFolders>
18+
<LogonCommand>
19+
<Command>C:\users\WDAGUtilityAccount\Desktop\startup\startup.cmd</Command>
20+
</LogonCommand>
21+
</Configuration>

scenarios/csharp/startup.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
REM install dotnet
2+
powershell.exe -command "& {Set-ExecutionPolicy -ExecutionPolicy Bypass -Force;. 'C:\users\WDAGUtilityAccount\Desktop\startup\install-dotnet.ps1' -Verbose;}"
3+
REM install vscode
4+
powershell.exe -command "& {Set-ExecutionPolicy -ExecutionPolicy Bypass -Force;. 'C:\users\WDAGUtilityAccount\Desktop\startup\install-vscode.ps1' -Verbose;}"

src/scripts/install-dotnet.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$zipPath = "C:\users\WDAGUtilityAccount\Desktop\Downloads\dotnet.zip"
2+
3+
4+
$sharePath = "$env:LocalAppData\Microsoft\dotnet";
5+
mkdir $sharePath -Force;
6+
Expand-Archive -Path $zipPath -DestinationPath $sharePath;
7+
# for the user
8+
[System.Collections.ArrayList]$currentPath = ([System.Environment]::GetEnvironmentVariable('PATH',[System.EnvironmentVariableTarget]::User)).Split(';');
9+
$currentPath.Add($sharePath);
10+
[System.Environment]::SetEnvironmentVariable('PATH', ($currentPath -join ';'),[System.EnvironmentVariableTarget]::User);
11+
#for the current process
12+
[System.Collections.ArrayList]$currentPath = ([System.Environment]::GetEnvironmentVariable('PATH',[System.EnvironmentVariableTarget]::Process)).Split(';');
13+
$currentPath.Add($sharePath);
14+
[System.Environment]::SetEnvironmentVariable('PATH', ($currentPath -join ';'),[System.EnvironmentVariableTarget]::Process);

src/scripts/update-dotnet.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter()]
4+
[switch]
5+
$ForceUpdate
6+
)
7+
8+
function Get-CurrentVersion{
9+
# request magic url form the dotnet install script
10+
$versionInformation = Invoke-RestMethod -Uri "https://dotnetcli.blob.core.windows.net/dotnet/Sdk/LTS/latest.version";
11+
# version number is always the last line
12+
return (-split $versionInformation)[-1];
13+
}
14+
15+
$outPath = "$PSScriptRoot\..\downloads\dotnet.zip"
16+
17+
if($ForceUpdate.IsPresent){
18+
Remove-Item -Force $outPath;
19+
}
20+
if(Test-Path $outPath){
21+
return;
22+
}
23+
$SpecificVersion = Get-CurrentVersion;
24+
# magic url from the dotnet install script
25+
Invoke-WebRequest ("https://dotnetcli.azureedge.net/dotnet/Sdk/$SpecificVersion/dotnet-sdk-$SpecificVersion-win-x64.zip") -OutFile $outPath;

0 commit comments

Comments
 (0)