Teronis.MSBuild.Packaging.ProjectBuildInPackage 1.0.2

Prefix Reserved
Suggested Alternatives

Tenekon.MSBuild.Packaging.ProjectBuildInPackage 2.0.0

Additional Details

The package "Teronis.*" has been rebranded to "Tenekon.*".

dotnet add package Teronis.MSBuild.Packaging.ProjectBuildInPackage --version 1.0.2                
NuGet\Install-Package Teronis.MSBuild.Packaging.ProjectBuildInPackage -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Teronis.MSBuild.Packaging.ProjectBuildInPackage" Version="1.0.2">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Teronis.MSBuild.Packaging.ProjectBuildInPackage --version 1.0.2                
#r "nuget: Teronis.MSBuild.Packaging.ProjectBuildInPackage, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Teronis.MSBuild.Packaging.ProjectBuildInPackage as a Cake Addin
#addin nuget:?package=Teronis.MSBuild.Packaging.ProjectBuildInPackage&version=1.0.2

// Install Teronis.MSBuild.Packaging.ProjectBuildInPackage as a Cake Tool
#tool nuget:?package=Teronis.MSBuild.Packaging.ProjectBuildInPackage&version=1.0.2                

Teronis.MSBuild.Packaging.ProjectBuildInPackage Nuget

Allow project reference content to be added to the NuGet-package during pack process.

Was recently part of the Teronis.DotNet code base but Teronis.MSBuild.Packaging.ProjectBuildInPackage deserves its own repository.

Installation

Package Managaer

Install-Package Teronis.MSBuild.Packaging.ProjectBuildInPackage -Version <type here version>

.NET CLI

dotnet add package Teronis.MSBuild.Packaging.ProjectBuildInPackage --version <type here version>

Settings

Disable welcome message

<PropertyGroup>
  <NoProjectBuildInPackageWelcome>false</NoProjectBuildInPackageWelcome>
</PropertyGroup>

Modify verbosity

</PropertyGroup>
  
  <ProjectBuildInPackageVerbosity>normal</ProjectBuildInPackageVerbosity>
</PropertyGroup>

Usage

1. Specify PrivateAssets="all" to those <ProjectReference ... />s whose build artefacts you want to have to be included into the package. <br/>2. Pack your project.

Example:

Before

<PropertyGroup>
  <TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
  <AssemblyName>Teronis.NetStandard.Core</AssemblyName>
</PropertyGroup>
<ItemGroup>
  <ProjectReference Include="..\..\Core.Localization\src\Teronis.NetStandard.Core.Localization.csproj" />
</ItemGroup>

After

<PropertyGroup>
  <TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
  <AssemblyName>Teronis.NetStandard.Core</AssemblyName>
</PropertyGroup>
<ItemGroup>
  <ProjectReference Include="..\..\Core.Localization\src\Teronis.NetStandard.Core.Localization.csproj" PrivateAssets="all" />
</ItemGroup>

Verification

There are three ways to verify that it worked:

1. Look at the console output and seek out for something like this:

3>Target _WalkEachTargetPerFramework:
3>  Target CopyProjectBuildInPackage:
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Thanks for using my package. <3
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.dll (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.pdb (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.xml (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\de-DE\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\de-DE\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\en-US\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\en-US\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\nl-NL\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\nl-NL\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] 6 local files have been copied to package. (TargetFramework=net5.0)
3>  Target CopyProjectBuildInPackage:
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Thanks for using my package. <3
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.dll (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.pdb (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.xml (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\de-DE\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\de-DE\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\en-US\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\en-US\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\nl-NL\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\nl-NL\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] 6 local files have been copied to package. (TargetFramework=netcoreapp3.1)
3>  Target CopyProjectBuildInPackage:
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Thanks for using my package. <3
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.dll (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.pdb (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\Teronis.NetStandard.Core.Localization.xml (local) to .\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\de-DE\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\de-DE\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\en-US\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\en-US\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] Copy ..\..\Core.Localization\src\bin\Debug\netstandard2.0\nl-NL\Teronis.NetStandard.Core.Localization.resources.dll (local) to .\nl-NL\ (package)
3>    [Teronis.MSBuild.Packaging.ProjectBuildInPackage] 6 local files have been copied to package. (TargetFramework=netstandard2.0)

This indicates that in each framework in project Teronis.NetStandard.Core the framework specific files from project Teronis.NetStandard.Core.Localization has been added to package.

2. Unzip the .nupkg and look inside the *.nuspec-file

It should look like this:

<dependencies>
  <group targetFramework=".NETCoreApp3.1">
    <dependency id="Microsoft.Bcl.HashCode" version="1.1.1" exclude="Build,Analyzers" />
    <dependency id="Microsoft.CSharp" version="4.7.0" exclude="Build,Analyzers" />
    <dependency id="Microsoft.Extensions.Logging.Abstractions" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="MorseCode.ITask" version="2.0.3" exclude="Build,Analyzers" />
    <dependency id="System.Configuration.ConfigurationManager" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Interactive.Async" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Management" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Text.Json" version="5.0.1" exclude="Build,Analyzers" />
    <dependency id="System.Threading.Tasks.Dataflow" version="5.0.0" exclude="Build,Analyzers" />
  </group>
  <group targetFramework="net5.0">
    <dependency id="Microsoft.Bcl.HashCode" version="1.1.1" exclude="Build,Analyzers" />
    <dependency id="Microsoft.CSharp" version="4.7.0" exclude="Build,Analyzers" />
    <dependency id="Microsoft.Extensions.Logging.Abstractions" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="MorseCode.ITask" version="2.0.3" exclude="Build,Analyzers" />
    <dependency id="System.Configuration.ConfigurationManager" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Interactive.Async" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Management" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Text.Json" version="5.0.1" exclude="Build,Analyzers" />
    <dependency id="System.Threading.Tasks.Dataflow" version="5.0.0" exclude="Build,Analyzers" />
  </group>
  <group targetFramework=".NETStandard2.0">
    <dependency id="Teronis.Nullable" version="0.1.8-alpha.202" exclude="Build,Analyzers" />
    <dependency id="Microsoft.Bcl.HashCode" version="1.1.1" exclude="Build,Analyzers" />
    <dependency id="Microsoft.CSharp" version="4.7.0" exclude="Build,Analyzers" />
    <dependency id="Microsoft.Extensions.Logging.Abstractions" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="MorseCode.ITask" version="2.0.3" exclude="Build,Analyzers" />
    <dependency id="System.Configuration.ConfigurationManager" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Interactive.Async" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Management" version="5.0.0" exclude="Build,Analyzers" />
    <dependency id="System.Text.Json" version="5.0.1" exclude="Build,Analyzers" />
    <dependency id="System.Threading.Tasks.Dataflow" version="5.0.0" exclude="Build,Analyzers" />
  </group>
</dependencies>

There should no entry listed that looks like:

<dependency id="Teronis.NetStandard.Core.Localization" version="0.1.8-alpha.202" exclude="Build,Analyzers" />

3. Unzip the .nupkg and look inside lib/<target-framework>/ whether Teronis.NetStandard.Core.Localization.(dll|pdb|xml) is present.

Frequent questions

Question <br/>Why NuGet package does not include all dependencies when packing?

Answer <br/>Let's first assume the following:


<ItemGroup>
  <PackageReference Include="SomePackage" Version="*" />
</ItemGroup>


<ItemGroup>
  <ProjectReference Include="ProjectA" PrivateAssets="all">
  
</ItemGroup>

You are telling NuGet that you don't want to have Project A to be picked up as NuGet-dependency. This is implicit, you don't have control about that. The down-side is the assmeblies of Project A, but not the assemblies of the packages of Project A, are not present in package of Project B.

By removing PrivateAssets="all" you disable the implicit behaviour of NuGet and the Project A will be picked up as NuGet dependency and EACH non-dependency package (also called transitive package).

Now let's asumme this:


<ItemGroup>
  <PackageReference Include="SomePackage" Version="*" />
</ItemGroup>


<ItemGroup>
  <ProjectReference Include="ProjectA" PrivateAssets="all">
  <PackageReference Include="Teronis.MSBuild.Packaging.ProjectBuildInPackage" Version="0.1.7" />
</ItemGroup>

By having installed my package I assist in the implicit behaviour of NuGet: By not picking up Project A as NuGet-dependency copy over the direct assemblies produced by Project A to the bin-folder of Project B. This has the following drawback:

Because of the implicit behaviour and the usage of my package you have assemblies of Project A in Project B that are in need of the assemblies provided by packages (in your example "Some Package") you referenced in Project A. So a workaround is to add the packages from Project A in Project B explicitly as shown here:


<ItemGroup>
  <PackageReference Include="SomePackage" Version="*" />
</ItemGroup>


<ItemGroup>
  <ProjectReference Include="ProjectA" PrivateAssets="all">
  <PackageReference Include="Teronis.MSBuild.Packaging.ProjectBuildInPackage" Version="0.1.7" />
  
  <PackageReference Include="SomePackage" Version="*" />
</ItemGroup>
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Teronis.MSBuild.Packaging.ProjectBuildInPackage:

Package Downloads
Rookout

Rookout is a .NET package that supports on the fly debugging and data extraction from .NET applications in production.

SFA.DAS.Payments.ProviderPayments.Messages

Package Description

SFA.DAS.Payments.Monitoring.Jobs.DataMessages

Package Description

SFA.DAS.Payments.ProviderPayments.Messages.Core

Package Description

SFA.DAS.Payments.Monitoring.Jobs.Messages

Package Description

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on Teronis.MSBuild.Packaging.ProjectBuildInPackage:

Repository Stars
TabBlazor/TabBlazor
Blazor admin template based on Tabler UI
serilog-contrib/serilog-ui
Simple Serilog log viewer UI for several sinks.
ThereGoesMySanity/osuMissAnalyzer
A program to analyze misses in an osu! replay
usinesoft/Cachalot
Fastest transactional database for dotnet applications (classic or core); it can also be used as a high performance distributed cache
jxnkwlp/abp-elsa-module
Elsa abp module and workflow app
Version Downloads Last updated
1.0.2 623 9/19/2024 1.0.2 is deprecated.
1.0.0 420,654 11/21/2021
1.0.0-alpha.8 492 11/20/2021
0.1.8-alpha.223 31,117 4/7/2021
0.1.8-alpha.219 140 4/6/2021
0.1.8-alpha.180 175 3/29/2021
0.1.8-alpha.163 163 3/25/2021
0.1.8-alpha.156 171 3/25/2021
0.1.8-alpha.97 137 3/2/2021
0.1.8-alpha.65 211 1/23/2021
0.1.8-alpha.45 228 11/30/2020
0.1.7 1,005,950 8/10/2020
0.1.7-linq-expressions.50 253 7/19/2020
0.1.7-alpha.68 282 7/24/2020
0.1.7-alpha.66 240 7/23/2020
0.1.7-alpha.64 270 7/22/2020
0.1.7-alpha.61 279 7/22/2020
0.1.7-alpha.57 258 7/21/2020
0.1.7-alpha.52 237 7/19/2020
0.1.7-alpha.37 342 7/19/2020
0.1.7-alpha.24 229 7/17/2020
0.1.7-alpha.17 262 7/16/2020
0.1.7-alpha.15 271 7/16/2020
0.1.7-alpha.9 324 7/16/2020
0.1.7-alpha.5 265 7/13/2020
0.1.6 486 7/9/2020
0.1.6-alpha.26 216 6/29/2020
0.1.6-alpha.24 229 6/29/2020
0.1.5 817 6/13/2020
0.1.1 15,833 1/14/2020