Skip to content

Commit

Permalink
#16 Added packaging tasks to build script.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreypalermo committed Sep 30, 2022
1 parent a778045 commit 458bcf3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
9 changes: 8 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ steps:
displayName: 'Publish code coverage from $(System.DefaultWorkingDirectory)/**/UnitTests/coverage.cobertura.xml copy'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/IntegrationTests/coverage.cobertura.xml'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/IntegrationTests/coverage.cobertura.xml'

- task: NuGetCommand@2
displayName: 'NuGet push'
inputs:
command: push
packagesToPush: 'build\*.$(Build.BuildNumber).nupkg'
publishVstsFeed: 'ProgrammingWithPalermo/ChurchBulletin'
36 changes: 36 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ $source_dir = "$base_dir\src"
$unitTestProjectPath = "$source_dir\UnitTests"
$integrationTestProjectPath = "$source_dir\IntegrationTests"
$acceptanceTestProjectPath = "$source_dir\AcceptanceTests"
$uiProjectPath = "$source_dir\UI\Server"
$databaseProjectPath = "$source_dir\Database"
$projectConfig = $env:BuildConfiguration
$framework = "net6.0"
$version = $env:Version
Expand Down Expand Up @@ -112,6 +114,39 @@ Function MigrateDatabaseLocal {
}
}

Function PackageUI {
exec{
& dotnet publish $uiProjectPath -nologo --no-restore --no-build -v $verbosity --configuration $projectConfig
}
exec{
& dotnet-octo pack --id "$projectName.UI" --version $version --basePath $uiProjectPath\bin\$projectConfig\$framework\publish --outFolder $build_dir --overwrite
}
}

Function PackageDatabase {
exec{
& dotnet-octo pack --id "$projectName.Database" --version $version --basePath $databaseProjectPath --outFolder $build_dir --overwrite
}
}

Function PackageAcceptanceTests {
# Use Debug configuration so full symbols are available to display better error messages in test failures
exec{
& dotnet publish $acceptanceTestProjectPath -nologo --no-restore -v $verbosity --configuration Debug
}
exec{
& dotnet-octo pack --id "$projectName.AcceptanceTests" --version $version --basePath $acceptanceTestProjectPath\bin\Debug\$framework\publish --outFolder $build_dir --overwrite
}
}

Function Package{
Write-Output "Packaging nuget packages"
dotnet tool install --global Octopus.DotNet.Cli | Write-Host $_ #prevents red color is already installed
PackageUI
PackageDatabase
PackageAcceptanceTests
}

Function PrivateBuild{
$projectConfig = "Debug"
$sw = [Diagnostics.Stopwatch]::StartNew()
Expand All @@ -132,6 +167,7 @@ Function CIBuild{
UnitTests
MigrateDatabaseLocal
IntegrationTest
Package
$sw.Stop()
write-host "Build time: " $sw.Elapsed.ToString()
}
13 changes: 7 additions & 6 deletions src/IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
</PropertyGroup>

<ItemGroup>
<None Remove="appsettings.test.json" />
<None Remove="coverage.cobertura.xml" />
</ItemGroup>

<ItemGroup>
<Content Include="appsettings.test.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -37,10 +44,4 @@
<ProjectReference Include="..\UI\Server\UI.Server.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/IntegrationTests/TestHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private static void Initialize()
var env = context.HostingEnvironment;

config
.AddJsonFile("appsettings.json", false, true)
.AddJsonFile("appsettings.test.json", false, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddEnvironmentVariables();
})
Expand Down
File renamed without changes.

0 comments on commit 458bcf3

Please sign in to comment.