Skip to content

Commit

Permalink
Merge pull request #543 from bothzoli/create-strong-named-nuget-package
Browse files Browse the repository at this point in the history
Create strong named assembiles
  • Loading branch information
vkhorikov authored Jun 23, 2024
2 parents 8901606 + 71f669c commit 4414c0e
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.Build.props"/>

<PropertyGroup>
<PackageId>CSharpFunctionalExtensions.StrongName</PackageId>
<AssemblyOriginatorKeyFile>CSharpFunctionalExtensions.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net45'">
<AssemblyTitle>CSharpFunctionalExtensions (with a strong name) .NET 4.5</AssemblyTitle>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net461'">
<AssemblyTitle>CSharpFunctionalExtensions (with a strong name) .NET 4.6.1</AssemblyTitle>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<AssemblyTitle>CSharpFunctionalExtensions (with a strong name) .NET Standard 2.0</AssemblyTitle>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net5.0'">
<AssemblyTitle>CSharpFunctionalExtensions (with a strong name) .NET 5.0</AssemblyTitle>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net6.0'">
<AssemblyTitle>CSharpFunctionalExtensions (with a strong name) .NET 6.0</AssemblyTitle>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net40'">
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="!$(DefineConstants.Contains('NET5_0_OR_GREATER')) and !$(DefineConstants.Contains('NETCORE'))">
<EmbeddedResource Remove="Result\Json\Serialization\**"/>
<None Remove="Result\Json\Serialization\**"/>
<Compile Include="..\CSharpFunctionalExtensions\**\*.cs"
Exclude="..\CSharpFunctionalExtensions\obj\**\*.cs;..\CSharpFunctionalExtensions\Result\Json\Serialization\**"/>
</ItemGroup>

<ItemGroup Condition="$(DefineConstants.Contains('NET5_0_OR_GREATER')) or $(DefineConstants.Contains('NETCORE'))">
<Compile Include="..\CSharpFunctionalExtensions\**\*.cs" Exclude="..\CSharpFunctionalExtensions\obj\**\*.cs"/>
</ItemGroup>

</Project>
Binary file not shown.
7 changes: 7 additions & 0 deletions CSharpFunctionalExtensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Dockerfile = Dockerfile
README.md = README.md
version.txt = version.txt
Common.Build.props = Common.Build.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpFunctionalExtensions.StrongName", "CSharpFunctionalExtensions.StrongName\CSharpFunctionalExtensions.StrongName.csproj", "{A86176EF-DCC2-44E5-8F0F-D5F58006DEBB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -37,6 +40,10 @@ Global
{AAC59D01-6546-4366-B990-4A765EF4D796}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAC59D01-6546-4366-B990-4A765EF4D796}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAC59D01-6546-4366-B990-4A765EF4D796}.Release|Any CPU.Build.0 = Release|Any CPU
{A86176EF-DCC2-44E5-8F0F-D5F58006DEBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A86176EF-DCC2-44E5-8F0F-D5F58006DEBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A86176EF-DCC2-44E5-8F0F-D5F58006DEBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A86176EF-DCC2-44E5-8F0F-D5F58006DEBB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
39 changes: 12 additions & 27 deletions CSharpFunctionalExtensions/CSharpFunctionalExtensions.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.Build.props"/>

<PropertyGroup>
<TargetFrameworks>net40;net45;net461;netstandard2.0;net5.0;net6.0</TargetFrameworks>
<PackageId>CSharpFunctionalExtensions</PackageId>
<Authors>Vladimir Khorikov</Authors>
<Description>CSharpFunctionalExtensions - functional extensions for C#</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>C# Functional</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://enterprisecraftsmanship.com/ps-func</PackageProjectUrl>
<RepositoryUrl>https://github.com/vkhorikov/CSharpFunctionalExtensions/</RepositoryUrl>
<NeutralLanguage>en-US</NeutralLanguage>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<LangVersion>9.0</LangVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<NoWarn>1591;1701;1702</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net45'">
Expand All @@ -38,14 +23,14 @@

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>CSharpFunctionalExtensions.Tests</_Parameter1>
<_Parameter1>CSharpFunctionalExtensions.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net40'">
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168" />
<PackageReference Include="Microsoft.Bcl.Async" Version="1.0.168"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -54,9 +39,9 @@
</ItemGroup>

<ItemGroup Condition="!$(DefineConstants.Contains('NET5_0_OR_GREATER')) and !$(DefineConstants.Contains('NETCORE'))">
<Compile Remove="Result\Json\Serialization\**" />
<EmbeddedResource Remove="Result\Json\Serialization\**" />
<None Remove="Result\Json\Serialization\**" />
<Compile Remove="Result\Json\Serialization\**"/>
<EmbeddedResource Remove="Result\Json\Serialization\**"/>
<None Remove="Result\Json\Serialization\**"/>
<Compile Update="Result\Methods\Extensions\BindIf.Task.cs">
<DependentUpon>BindIf.cs</DependentUpon>
</Compile>
Expand Down Expand Up @@ -118,13 +103,13 @@
<DependentUpon>GetValueOrDefault.cs</DependentUpon>
</Compile>
<Compile Update="Maybe\Extensions\Map.Task.cs">
<DependentUpon>Map.cs</DependentUpon>
<DependentUpon>Map.cs</DependentUpon>
</Compile>
<Compile Update="Maybe\Extensions\AsMaybe.Task.cs">
<DependentUpon>AsMaybe.cs</DependentUpon>
<DependentUpon>AsMaybe.cs</DependentUpon>
</Compile>
<Compile Update="Maybe\Extensions\AsMaybe.ValueTask.cs">
<DependentUpon>AsMaybe.cs</DependentUpon>
<DependentUpon>AsMaybe.cs</DependentUpon>
</Compile>
<Compile Update="Result\Methods\Extensions\MapIf.Task.cs">
<DependentUpon>MapIf.cs</DependentUpon>
Expand Down Expand Up @@ -664,7 +649,7 @@
<DependentUpon>MapTry.ValueTask.cs</DependentUpon>
</Compile>
<Compile Update="Result\Methods\Extensions\GetValueOrDefault.Task.cs">
<DependentUpon>GetValueOrDefault.cs</DependentUpon>
<DependentUpon>GetValueOrDefault.cs</DependentUpon>
</Compile>
<Compile Update="Result\Methods\Extensions\GetValueOrDefault.Task.Right.cs">
<DependentUpon>GetValueOrDefault.Task.cs</DependentUpon>
Expand Down
21 changes: 21 additions & 0 deletions Common.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net40;net45;net461;netstandard2.0;net5.0;net6.0</TargetFrameworks>
<Authors>Vladimir Khorikov</Authors>
<Description>CSharpFunctionalExtensions - functional extensions for C#</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>C# Functional</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://enterprisecraftsmanship.com/ps-func</PackageProjectUrl>
<RepositoryUrl>https://github.com/vkhorikov/CSharpFunctionalExtensions/</RepositoryUrl>
<NeutralLanguage>en-US</NeutralLanguage>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<LangVersion>9.0</LangVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<NoWarn>1591;1701;1702</NoWarn>
</PropertyGroup>
</Project>
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
ARG Version
WORKDIR /app

COPY ./Common.Build.props ./
COPY ./CSharpFunctionalExtensions/CSharpFunctionalExtensions.csproj ./CSharpFunctionalExtensions/
COPY ./CSharpFunctionalExtensions.StrongName/CSharpFunctionalExtensions.StrongName.csproj ./CSharpFunctionalExtensions.StrongName/
COPY ./CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj ./CSharpFunctionalExtensions.Tests/
RUN dotnet restore ./CSharpFunctionalExtensions/CSharpFunctionalExtensions.csproj
RUN dotnet restore ./CSharpFunctionalExtensions.StrongName/CSharpFunctionalExtensions.StrongName.csproj
RUN dotnet restore ./CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj

COPY ./CSharpFunctionalExtensions ./CSharpFunctionalExtensions
COPY ./CSharpFunctionalExtensions.StrongName ./CSharpFunctionalExtensions.StrongName
COPY ./CSharpFunctionalExtensions.Tests ./CSharpFunctionalExtensions.Tests
RUN dotnet build -c Release --no-restore "./CSharpFunctionalExtensions/CSharpFunctionalExtensions.csproj" /p:Version=$Version
RUN dotnet build -c Release --no-restore "./CSharpFunctionalExtensions.StrongName/CSharpFunctionalExtensions.StrongName.csproj" /p:Version=$Version
RUN dotnet build -c Release --no-restore "./CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj" /p:Version=$Version

RUN dotnet test "./CSharpFunctionalExtensions.Tests/CSharpFunctionalExtensions.Tests.csproj" -c Release --no-build --no-restore --logger "trx;LogFileName=testresults.trx"; exit 0

RUN dotnet pack "./CSharpFunctionalExtensions/CSharpFunctionalExtensions.csproj" -c Release --no-restore --no-build -o /app/out /p:Version=$Version
RUN dotnet pack "./CSharpFunctionalExtensions.StrongName/CSharpFunctionalExtensions.StrongName.csproj" -c Release --no-restore --no-build -o /app/out-sn /p:Version=$Version
24 changes: 20 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ stages:
displayName: Read versions
steps:
- powershell: |
$newVersion = Get-Content "$(Build.SourcesDirectory)/$(versionFileName)" -First 1
$newVersion = Get-Content "$(Build.SourcesDirectory)/$(versionFileName)" -First 1
$releaseInfo = (Get-Content "$(Build.SourcesDirectory)/$(versionFileName)" | Select-Object -Skip 1).Replace('\r\n', '\n')
echo "##vso[task.setvariable variable=newVersion;isOutput=true]$($newVersion)"
echo "##vso[task.setvariable variable=releaseInfo;isOutput=true]$($releaseInfo)"
Expand All @@ -34,6 +34,7 @@ stages:
- job: BuildAndTest
displayName: Build and test
dependsOn: Version
condition: succeeded('Version')
variables:
newVersion: $[ dependencies.Version.outputs['readNewVersionStep.newVersion'] ]
steps:
Expand All @@ -56,11 +57,15 @@ stages:
- script: |
docker create --name build-container build-image
docker cp build-container:./app/out ./out
docker cp build-container:./app/out-sn ./out-sn
displayName: Copy artifacts
- publish: ./out
artifact: NuGetPackage

- publish: ./out-sn
artifact: NuGetPackageStrongName

- job: Publish
dependsOn:
- Version
Expand All @@ -71,9 +76,9 @@ stages:
currentVersion: $[ dependencies.Version.outputs['readCurrentVersionStep.currentVersion'] ]
contentTypeHeader1: 'Content-Type: application/json'
contentTypeHeader2: 'Content-Type: application/octet-stream'
authHeader: 'Authorization: token $(gitHubToken)'
authHeader: 'Authorization: Bearer $(gitHubToken)'
createReleaseRequest: '{ "tag_name": "v$(newVersion)", "target_commitish": "master", "name": "v$(newVersion)", "body": "$(releaseInfo)", "draft": false, "prerelease": false }'
condition: ne(dependencies.Version.outputs['readNewVersionStep.newVersion'], dependencies.Version.outputs['readCurrentVersionStep.currentVersion'])
condition: and(succeeded('Version'), succeeded('BuildAndTest'), ne(dependencies.Version.outputs['readNewVersionStep.newVersion'], dependencies.Version.outputs['readCurrentVersionStep.currentVersion']))
steps:
- script: |
echo $(newVersion)
Expand All @@ -84,13 +89,24 @@ stages:
- download: current
artifact: NuGetPackage

- download: current
artifact: NuGetPackageStrongName

- script: |
curl -X POST -s -H '$(contentTypeHeader1)' -H '$(authHeader)' https://api.github.com/repos/vkhorikov/CSharpFunctionalExtensions/releases -d '$(createReleaseRequest)'
$json = Invoke-RestMethod -Method 'GET' -Uri "https://api.github.com/repos/vkhorikov/CSharpFunctionalExtensions/releases/latest"
$releaseId = $json.id
curl -X POST -s -H '$(contentTypeHeader2)' -H '$(authHeader)' -F 'data=@$(Pipeline.Workspace)/NuGetPackage/CSharpFunctionalExtensions.$(newVersion).nupkg' https://uploads.github.com/repos/vkhorikov/CSharpFunctionalExtensions/releases/$(releaseId)/assets?name=CSharpFunctionalExtensions.$(newVersion).nupkg
curl -X POST -s -H '$(contentTypeHeader2)' -H '$(authHeader)' --data-binary '$(Pipeline.Workspace)/NuGetPackage/CSharpFunctionalExtensions.$(newVersion).nupkg' 'https://uploads.github.com/repos/vkhorikov/CSharpFunctionalExtensions/releases/$(releaseId)/assets?name=CSharpFunctionalExtensions.$(newVersion).nupkg'
curl -X POST -s -H '$(contentTypeHeader2)' -H '$(authHeader)' --data-binary '$(Pipeline.Workspace)/NuGetPackageStrongName/CSharpFunctionalExtensions.StrongName.$(newVersion).nupkg' 'https://uploads.github.com/repos/vkhorikov/CSharpFunctionalExtensions/releases/$(releaseId)/assets?name=CSharpFunctionalExtensions.StrongName.$(newVersion).nupkg'
displayName: Publish to GitHub
condition: and(succeeded(), ne(variables.gitHubToken, ''))
- script: |
dotnet nuget push $(Pipeline.Workspace)/NuGetPackage/CSharpFunctionalExtensions.$(newVersion).nupkg --source https://api.nuget.org/v3/index.json --api-key $(nugetToken)
displayName: Publish to NuGet
condition: and(succeeded(), ne(variables.nugetToken, ''))
- script: |
dotnet nuget push $(Pipeline.Workspace)/NuGetPackage/CSharpFunctionalExtensions.StrongName.$(newVersion).nupkg --source https://api.nuget.org/v3/index.json --api-key $(nugetToken)
displayName: Publish strong named package to NuGet
condition: and(succeeded(), ne(variables.nugetToken, ''))
6 changes: 3 additions & 3 deletions version.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
2.42.0
2.42.1
New features:
* #540 Add BindZip to return the Tuple of merged Binds
* None

Fixed issues:
* None
* #27 Add strong named assembly

0 comments on commit 4414c0e

Please sign in to comment.