Skip to content

Commit

Permalink
- New scripts/Makefile step "setup" installs all required .NET versio…
Browse files Browse the repository at this point in the history
…ns and third-party tools (#299)
  • Loading branch information
nwithan8 authored Jul 13, 2022
1 parent a2f6446 commit fecd4ea
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ scan:
security-scan --verbose --no-banner --ignore-msbuild-errors EasyPost.sln
# "--ignore-msbuild-errors" needed since MSBuild does not like F#: https://github.com/security-code-scan/security-code-scan/issues/235

## setup - Install required .NET versions and tools (Windows only)5
setup:
scripts\setup.bat

.PHONY: help release build-dev build install-cert sign clean restore lint lint-check test lint-scripts install-scanner scan
2 changes: 1 addition & 1 deletion scripts/publish_all_nuget.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:: This script will find and publish any NuGet packages to Nuget.org
:: This script will find and publish any NuGet packages to Nuget.org

:: Requirements:
:: - NuGet is installed on the machine and is accessible everywhere (added to PATH)
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish_nuget.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:: This script will find and publish a NuGet packages to Nuget.org
:: This script will find and publish a NuGet packages to Nuget.org

:: Requirements:
:: - NuGet is installed on the machine and is accessible everywhere (added to PATH)
Expand Down
49 changes: 49 additions & 0 deletions scripts/setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
:: This script will:
:: - use Microsoft's PowerShell script (https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script) to install the latest version of all required .NET SDKs.
:: - install required third-party tools for running these scripts
:: - add files to the current user's PATH environment variable

:: Requirements:
:: - PowerShell is enabled on the machine
:: - Do not install dotnet via any other method (including via installing Visual Studio/Rider). This might otherwise cause two conflicting versions of 'dotnet' to exist in your PATH

@ECHO OFF

:: .NET Versions we want to install and destination
SET NetVersions=Current 6.0 5.0 3.1
SET InstallPath=C:\dotnet

:: Dependencies for these scripts
SET DepFiles=SnInstallPfx.exe nuget.exe 7z.exe
SET FileHost=https://files.nateharr.is/netdeps/

:: Install each .NET version
@ECHO Installing .NET SDKs ...
SETLOCAL
for %%x IN (%NetVersions%) DO (
@ECHO Installing .NET %%x ...
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -InstallDir %InstallPath% -Channel %%x -Verbose"
)
ENDLOCAL

:: Download dependencies to the same directory as 'dotnet'
@ECHO Downloading third-party tools ...
SETLOCAL
for %%x IN (%DepFiles%) DO (
@ECHO Downloading %%x ...
powershell -NoProfile -ExecutionPolicy unrestricted -Command "Invoke-WebRequest -Uri '%FileHost%%%x' -OutFile '%InstallPath%\%%x'"
)
ENDLOCAL

:: Add dotnet folder to PATH
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Environment]::SetEnvironmentVariable('Path', $env:Path + ';%InstallPath%', 'User')"

EXIT /B 0

:commandFailed
@ECHO Command failed.
GOTO :exitWithError

:exitWithError
@ECHO Exiting...
EXIT /B 1

0 comments on commit fecd4ea

Please sign in to comment.