Last active
September 25, 2021 02:37
-
-
Save rufer7/3366de827f8107456a90faf022390456 to your computer and use it in GitHub Desktop.
Sample PowerShell build script to build C# code
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
Param | |
( | |
[string]$build = "Debug" | |
, | |
[switch]$test = $true | |
) | |
$msBuildPath = 'C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild'; | |
$msTestPath = 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\'; | |
$testResults = "TestResults.trx"; | |
$env:Path = $env:Path + ";" + $msTestPath; | |
nuget restore .\src\ArbitrarySolution.sln -MSBuildVersion 12; | |
& $msBuildPath src\ArbitrarySolution.sln /property:Configuration=$build; | |
if ($test) | |
{ | |
Write "Execute unit tests"; | |
if (Test-Path $testResults) | |
{ | |
rm $testResults; | |
} | |
MSTest.exe /testcontainer:.\src\ArbitrarySolution.Project1.Tests\bin\Debug\ArbitrarySolution.Project1.Tests.dll /testcontainer:.\src\ArbitrarySolution.Project2.Tests\bin\Debug\ArbitrarySolution.Project2.Tests.dll /resultsfile:$testResults; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment