Skip to content

Instantly share code, notes, and snippets.

@mjebrahimi
Created April 8, 2020 16:06
Show Gist options
  • Save mjebrahimi/4f6fc1fe206183ac84fac22d977c6db4 to your computer and use it in GitHub Desktop.
Save mjebrahimi/4f6fc1fe206183ac84fac22d977c6db4 to your computer and use it in GitHub Desktop.
.csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.1;netstandard2.0;netstandard2.1;net45;net461;netcoreapp2.1</TargetFrameworks>
<AssemblyName>EasyCompressor</AssemblyName>
<PackageId>EasyCompressor</PackageId>
<Title>EasyCompressor</Title>
<Product>EasyCompressor</Product>
<Version>1.0.0</Version>
<PackageVersion>1.0.0</PackageVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Authors>Mohammad Javad Ebrahimi</Authors>
<Company>Mohammad Javad Ebrahimi</Company>
<Copyright>Copyright © Mohammad Javad Ebrahimi 2020</Copyright>
<Description>EasyCompressor is an open-source compression abstraction library that supports and implements many compression algorithms such as Zstd, LZMA, LZ4, Snappy, Brotli, GZip and Deflate.</Description>
<PackageTags>Compression Decompression Compress Decompress Compressor Zstd Zstandard LZMA LZ4 Snappy Brotli GZip Deflate</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/mjebrahimi/EasyCompressor</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<GeneratePackageOnBuild Condition="'$(Configuration)'=='Release'">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>EasyCompressor.png</PackageIcon>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DebugSymbols>true</DebugSymbols>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!-- <SignAssembly>true</SignAssembly> -->
<!-- <AssemblyOriginatorKeyFile>../sign.snk</AssemblyOriginatorKeyFile> -->
<!-- <DelaySign>false</DelaySign> -->
<!-- <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign> -->
<!-- <DebugType>embedded</DebugType> -->
<!-- <Optimize>false</Optimize> -->
<!-- <Deterministic>true</Deterministic> -->
<!-- <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> -->
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0' OR '$(TargetFramework)'=='netstandard2.1' OR '$(TargetFramework)'=='net461' OR '$(TargetFramework)'=='netcoreapp2.1'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='netstandard1.1' OR '$(TargetFramework)'=='net45'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="1.1.1"/>
</ItemGroup>
<ItemGroup>
<None Include="..\EasyCompressor.png" Pack="true" PackagePath="" />
</ItemGroup>
<!--
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\SevenZip.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\SevenZip.xml</DocumentationFile>
<DocumentationFile>bin\Release\DotNetZip.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<DefineConstants>SPANSTREAM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'!='net45' AND '$(TargetFramework)'!='netstandard1.1'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2|AnyCPU'">
<ItemGroup>
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" Condition=" '$(TargetFramework)' == 'net45' " />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
</ItemGroup>
-->
</Project>
@mjebrahimi
Copy link
Author

SourceLink Tips (Updated)

Necessary for enabling SoruceLink

First: publish the repository URL in the built .nupkg (in the NuSpec element).
Second : embed source files that are not tracked by the source control manager in the PDB.

<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>

Approach 1: Distribute Symbol files (.pdb) via a Symbol Server (like Nuget.org)

Create snupkg file that includes pdb symbols alongside the main NuGet package (.nupkg)
Symbol files (.pdb) published to NuGet.org symbol server.
Therefor developers need to configure NuGet.org symbol server in their IDE
Then these symbols downloaded by a tool like Visual Studio on demand.

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

Approach 2: Distribute Symbol files (.pdb) by Embedding ino the Main package

Embedding symbol files (.pdb) in the main NuGet package (.nupkg)
The main package size will be larger but developers dons't need to configure symbol server in ther IDE

<DebugType>embedded</DebugType>

Alternative way to embedding symbol files is below but the above tag is recommended.

<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>

Using the Embedding way .snupkg files not generated and when you want to push nuget package with command (dotnet nuget push .nupkg)
You will receive an error "File does not exist (
.snupkg)". Therefor to resolve this, you must add --no-symbols true like below.

dotnet nuget push *.nupkg -s nuget.org -k ****** --no-symbols true

Deterministic Builds:

Deterministic builds ensure that the same binary is produced regardless of the machine building it, including paths to sources stored in the symbols.

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
    <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

More Info:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment