ARG PROJECT=Strata.Excel.Core ARG VERSION=0.0.0 ARG SONARURL='' ARG SONARLOGIN='' ARG SONARBRANCH='' ############### # Build image # ############### FROM ecr.ops.stratanetwork.net/strata.microsoft.dotnet.sdk:6.0 AS build ARG PROJECT ARG VERSION ARG SONARLOGIN ARG SONARURL ARG SONARBRANCH RUN apt-get --allow-releaseinfo-change update && apt-get install -y libgdiplus WORKDIR /src # Copy project files and restore COPY ["${PROJECT}.sln", "${PROJECT}.sln"] COPY src/**/*.csproj ./ RUN for file in $(ls *.csproj); do mkdir -p src/${file%.*}/ && mv $file src/${file%.*}/; done COPY tests/**/*.csproj ./ RUN for file in $(ls *.csproj); do mkdir -p tests/${file%.*}/ && mv $file tests/${file%.*}/; done RUN dotnet restore "${PROJECT}.sln" \ --source https://api.nuget.org/v3/index.json \ --source https://proget.sdt.local/nuget/nuget/v3/index.json # Copy files and build COPY . . RUN if [ "${SONARLOGIN}" != "" ] ; then dotnet sonarscanner begin \ /k:"${PROJECT}" \ /d:sonar.scm.provider=git \ /d:sonar.host.url="${SONARURL}" \ /d:sonar.login="${SONARLOGIN}" \ ${SONARBRANCH} \ /d:sonar.cs.opencover.reportsPaths="/src/cover.xml" \ /d:sonar.dependencyCheck.jsonReportPath=/src/buildlogs/dependency-check-report.json \ /d:sonar.dependencyCheck.htmlReportPath=/src/buildlogs/dependency-check-report.html \ /v:sonar.projectVersion="${VERSION}"; fi RUN dotnet build "${PROJECT}.sln" \ --configuration Release \ --no-restore # Run unit tests RUN dotnet test "${PROJECT}.sln" \ --configuration Release \ --no-restore \ --no-build \ --verbosity=normal \ -p:CollectCoverage=true \ -p:CoverletOutputFormat="opencover" \ -p:CoverletOutput=/src/cover.xml RUN dotnet pack "src/Strata.Excel.Core/Strata.Excel.Core.csproj" \ --configuration Release \ --no-restore \ --no-build \ --include-symbols \ --include-source \ --output /pack \ -property:PackageVersion=${VERSION} RUN dotnet pack "src/Strata.Excel.TestUtilities/Strata.Excel.TestUtilities.csproj" \ --configuration Release \ --no-restore \ --no-build \ --include-symbols \ --include-source \ --output /pack \ -property:PackageVersion=${VERSION} RUN if [ "${SONARLOGIN}" != "" ] ; then \ /dc/dependency-check/bin/dependency-check.sh -f JSON -f HTML -s . -o ./buildlogs \ --suppression ./sonarsuppressions.xml \ --noupdate --nodeAuditSkipDevDependencies --disableNodeJS \ --dbDriverName "com.microsoft.sqlserver.jdbc.SQLServerDriver" \ --connectionString "jdbc:sqlserver://ddensqldevops01.sdt.local;Database=DependencyCheck;encrypt=true;trustServerCertificate=true;" \ --dbUser "dcuser" --dbPassword "${SONARLOGIN}" && \ dotnet sonarscanner end /d:sonar.login="${SONARLOGIN}"; \ fi