Last active
October 11, 2024 16:57
-
-
Save chrisfcarroll/5271803942d7b0465a38d3f98a80cd11 to your computer and use it in GitHub Desktop.
DevAzure tasks and GOTCHAS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task: PowerShell@2 | |
displayName: "Dev Azure tasks and GOTCHAS" | |
inputs: | |
targetType: 'inline' | |
script: | | |
# Write your PowerShell commands here. | |
@" | |
DevAzure tasks and GOTCHAS: NuGet.config, MsBuild Path, Unit Tests, Integration Tests | |
"@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: PowerShell@2 | |
displayName: Ensure MsBuild Path using VsWhere | |
inputs: | |
targetType: 'inline' | |
script: | | |
# Write your PowerShell commands here. | |
if(get-command vswhere.exe -ErrorAction SilentlyContinue){ | |
"vs-where is in the path | |
------------------------" | |
vswhere.exe | |
}elseif(get-command $env:AGENT_HOMEDIRECTORY\externals\vswhere\vswhere.exe -ErrorAction SilentlyContinue){ | |
"vs-where is in `$env:AGENT_HOMEDIRECTORY\externals\vswhere\vswhere.exe | |
------------------------" | |
& "$env:AGENT_HOMEDIRECTORY\externals\vswhere\vswhere.exe" | |
"--> Adding vswhere to the Path" | |
$env:Path += ";$env:AGENT_HOMEDIRECTORY\externals\vswhere\" | |
Write-Host "##vso[task.setvariable variable=Path;]$env:Path" | |
} | |
else{ | |
throw "No VsWhere Found" | |
} | |
"vswhere.exe -products * -----------------------------" | |
& vswhere.exe -products * | |
$msBuildPath=(& vswhere -products * -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe) | |
if(-not ($msBuildPath -like "*msbuild.exe")){ | |
throw "vswhere.exe said `"$msBuildPath`" which doesn't end in MsBuild.exe" | |
} | |
$env:Path += ";" + (Split-Path $msBuildPath -Parent) | |
"Adding directory for `"$msBuildpath`" to the path" | |
Write-Host "##vso[task.setvariable variable=Path;]$env:Path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: CmdLine@2 | |
displayName: Build $(project) | |
inputs: | |
script: | | |
echo msbuild commandline: | |
echo msbuild /p:Configuration=$(configuration) /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="$(Build.Repository.Name)" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true | |
echo. | |
msbuild /p:Configuration=$(configuration) /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="$(Build.Repository.Name)" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task: PowerShell@2 | |
displayName: "NuGet.Config | check sources" | |
inputs: | |
targetType: 'inline' | |
script: | | |
# Write your PowerShell commands here. | |
@" | |
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<packageSources> | |
<add key="LocalCache" value="$(UserProfile)\.nuget\packages" /> | |
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> | |
<add key="A NuGet FileShare" value="\\Path\To\Your\Nuget\Share" /> | |
<add key="A DevAzure NuGet Feed" value="https://pkgs.dev.azure.com/YourOrg/_packaging/YourFeedName/nuget/v3/index.json" /> | |
</packageSources> | |
<packageRestore><add key="enabled" value="True" /><add key="automatic" value="True" /></packageRestore> | |
<bindingRedirects><add key="skip" value="False" /></bindingRedirects></configuration> | |
"@ | Out-File NuGet.config -Encoding ASCII | |
"----------------------" | |
cat nuget.config -ErrorAction Continue | |
"----------------------" | |
invoke-webrequest https://api.nuget.org/v3/index.json -ErrorAction Continue -UseBasicParsing | |
"----------------------" | |
gci \\Path\To\Your\Nuget\Share -ErrorAction Continue | Format-Table | |
"----------------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: DotNetCoreCLI@2 | |
displayName: Unit Tests | |
inputs: | |
command: 'test' | |
arguments: --filter "TestCategory != Integration" | |
projects: '$(solution)' | |
- task: DotNetCoreCLI@2 | |
displayName: Integration Tests | |
inputs: | |
command: 'test' | |
arguments: --filter "TestCategory=Integration" | |
projects: '$(solution)' | |
# don't stop the pipeline for an integration test error | |
continueOnError: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: VSTest@3 | |
displayName: "Unit Tests" | |
inputs: | |
testSelector: 'testAssemblies' | |
testAssemblyVer2: '**\*Tests.dll' | |
searchFolder: '$(System.DefaultWorkingDirectory)' | |
testFiltercriteria: TestCategory !~ Integration | |
- task: VSTest@3 | |
displayName: "Integration Tests" | |
inputs: | |
testSelector: 'testAssemblies' | |
testAssemblyVer2: '**\*Tests.dll' | |
searchFolder: '$(System.DefaultWorkingDirectory)' | |
testFiltercriteria: TestCategory ~ Integration | |
# don't stop the pipeline for an integration test error | |
continueOnError: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment