Extract version in separate csproj to have better dockerfile caching

This commit is contained in:
nicolas.dorier
2019-06-02 17:33:35 +09:00
parent 189280e602
commit 8f76bc0bcb
8 changed files with 29 additions and 19 deletions

View File

@@ -1,9 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<Import Project="../Version.csproj" Condition="Exists('../Version.csproj')" />
<Import Project="../Common.csproj" />
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.9" />

View File

@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Version.csproj" Condition="Exists('../Version.csproj')" />
<Import Project="../Common.csproj" />
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.3</LangVersion>

View File

@@ -1,12 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="../Version.csproj" Condition="Exists('../Version.csproj')" />
<Import Project="../Common.csproj" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<Version>1.0.3.106</Version>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
</PropertyGroup>
<PropertyGroup>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Build\dockerfiles\**" />

7
Common.csproj Normal file
View File

@@ -0,0 +1,7 @@
<Project>
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
</Project>

View File

@@ -1,12 +1,14 @@
FROM mcr.microsoft.com/dotnet/core/sdk:2.1.505-alpine3.7 AS builder
WORKDIR /source
COPY Common.csproj Common.csproj
COPY BTCPayServer/BTCPayServer.csproj BTCPayServer/BTCPayServer.csproj
COPY BTCPayServer.Common/BTCPayServer.Common.csproj BTCPayServer.Common/BTCPayServer.Common.csproj
COPY BTCPayServer.Rating/BTCPayServer.Rating.csproj BTCPayServer.Rating/BTCPayServer.Rating.csproj
RUN cd BTCPayServer && dotnet restore
COPY BTCPayServer/. .
COPY BTCPayServer.Rating/. .
COPY BTCPayServer.Common/. .
COPY Version.csproj Version.csproj
COPY BTCPayServer/. BTCPayServer/.
COPY BTCPayServer.Rating/. BTCPayServer.Rating/.
COPY BTCPayServer.Common/. BTCPayServer.Common/.
RUN cd BTCPayServer && dotnet publish --output /app/ --configuration Release
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1.9-alpine3.7

View File

@@ -4,13 +4,15 @@ RUN apt-get update \
&& apt-get install -qq --no-install-recommends qemu qemu-user-static qemu-user binfmt-support
WORKDIR /source
COPY Common.csproj Common.csproj
COPY BTCPayServer/BTCPayServer.csproj BTCPayServer/BTCPayServer.csproj
COPY BTCPayServer.Common/BTCPayServer.Common.csproj BTCPayServer.Common/BTCPayServer.Common.csproj
COPY BTCPayServer.Rating/BTCPayServer.Rating.csproj BTCPayServer.Rating/BTCPayServer.Rating.csproj
RUN dotnet restore
COPY BTCPayServer/. .
COPY BTCPayServer.Rating/. .
COPY BTCPayServer.Common/. .
COPY Version.csproj Version.csproj
COPY BTCPayServer/. BTCPayServer/.
COPY BTCPayServer.Rating/. BTCPayServer.Rating/.
COPY BTCPayServer.Common/. BTCPayServer.Common/.
RUN cd BTCPayServer && dotnet publish --output /app/ --configuration Release
# Force the builder machine to take make an arm runtime image. This is fine as long as the builder does not run any program

5
Version.csproj Normal file
View File

@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.0.3.106</Version>
</PropertyGroup>
</Project>

View File

@@ -1,4 +1,4 @@
$ver = [regex]::Match((Get-Content BTCPayServer\BTCPayServer.csproj), '<Version>([^<]+)<').Groups[1].Value
$ver = [regex]::Match((Get-Content Version.csproj), '<Version>([^<]+)<').Groups[1].Value
git tag -a "v$ver" -m "$ver"
git checkout latest
git merge master