diff --git a/eng/pipelines/templates/BuildAndTest.yml b/eng/pipelines/templates/BuildAndTest.yml index 174fe6fd905..fc2b4ee4f8a 100644 --- a/eng/pipelines/templates/BuildAndTest.yml +++ b/eng/pipelines/templates/BuildAndTest.yml @@ -60,12 +60,7 @@ steps: - ${{ if and(eq(parameters.runAsPublic, 'true'), eq(parameters.runPipelineTests, 'true')) }}: # non-helix tests - ${{ if ne(parameters.isWindows, 'true') }}: - - script: mkdir ${{ parameters.repoArtifactsPath }}/devcert-scripts && - cd ${{ parameters.repoArtifactsPath }}/devcert-scripts && - wget https://raw.githubusercontent.com/BorisWilhelms/create-dotnet-devcert/main/scripts/ubuntu-create-dotnet-devcert.sh && - wget https://raw.githubusercontent.com/BorisWilhelms/create-dotnet-devcert/main/scripts/common.sh && - chmod +x ubuntu-create-dotnet-devcert.sh && - ./ubuntu-create-dotnet-devcert.sh + - script: $(Build.SourcesDirectory)/tests/external-scripts/ubuntu-create-dotnet-devcert.sh displayName: Install devcerts - ${{ if eq(parameters.isWindows, 'true') }}: diff --git a/tests/external-scripts/README.md b/tests/external-scripts/README.md new file mode 100644 index 00000000000..5099100c013 --- /dev/null +++ b/tests/external-scripts/README.md @@ -0,0 +1,3 @@ +# external-scripts + +This is a copy of scripts from https://github.com/BorisWilhelms/create-dotnet-devcert/ . This is being used for now as `dotnet dev-certs https --trust` doesn't seem to be working on our CI. diff --git a/tests/external-scripts/common.sh b/tests/external-scripts/common.sh new file mode 100644 index 00000000000..3dcd708482c --- /dev/null +++ b/tests/external-scripts/common.sh @@ -0,0 +1,98 @@ +#!/bin/sh +SAVE=0 + +usage() { + echo "Usage: $0 [-s]" + echo "Generates a valid ASP.NET Core self-signed certificate for the local machine." + echo "The certificate will be imported into the system's certificate store and into various other places." + echo " -s: Also saves the generated crtfile to the home directory" + exit 1 +} + +while getopts "sh" opt +do + case "$opt" in + s) + SAVE=1 + ;; + h) + usage + exit 1 + ;; + *) + ;; + esac +done + +TMP_PATH=/var/tmp/localhost-dev-cert +if [ ! -d $TMP_PATH ]; then + mkdir $TMP_PATH +fi + +cleanup() { + rm -R $TMP_PATH +} + +KEYFILE=$TMP_PATH/dotnet-devcert.key +CRTFILE=$TMP_PATH/dotnet-devcert.crt +PFXFILE=$TMP_PATH/dotnet-devcert.pfx + +NSSDB_PATHS="$HOME/.pki/nssdb \ + $HOME/snap/chromium/current/.pki/nssdb \ + $HOME/snap/postman/current/.pki/nssdb" + +CONF_PATH=$TMP_PATH/localhost.conf +cat >> $CONF_PATH <$(RepoRoot).config/dotnet-tools.json <_DotNetToolJsonContent>$([System.IO.File]::ReadAllText($(_DotNetToolJsonPath))) - <_CreateDotNetDevCertsDirectory>$(ArtifactsObjDir)create-dotnet-devcert - <_AzureFunctionsCliUrl Condition="'$(OS)' == 'Windows_NT'">https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.6280/Azure.Functions.Cli.min.win-x64_net8.4.0.6280.zip <_AzureFunctionsCliUrl Condition="'$(OS)' != 'Windows_NT'">https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.6280/Azure.Functions.Cli.linux-x64_net8.4.0.6280.zip <_DefaultSdkDirNameForTests>dotnet-tests - - _StageCreateDotNetDevCertScripts @@ -164,11 +160,6 @@ - - - - - @@ -187,7 +178,7 @@ - +