Teronis.MSBuild.Packaging.ProjectBuildInPackage
1.0.2
Prefix Reserved
Tenekon.MSBuild.Packaging.ProjectBuildInPackage 2.0.0
Additional DetailsThe 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
<PackageReference Include="Teronis.MSBuild.Packaging.ProjectBuildInPackage" Version="1.0.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Teronis.MSBuild.Packaging.ProjectBuildInPackage --version 1.0.2
#r "nuget: Teronis.MSBuild.Packaging.ProjectBuildInPackage, 1.0.2"
// 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
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>
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 (4)
Showing the top 4 popular GitHub repositories that depend on Teronis.MSBuild.Packaging.ProjectBuildInPackage:
Repository | Stars |
---|---|
TabBlazor/TabBlazor
Blazor admin template based on Tabler UI
|
|
ThereGoesMySanity/osuMissAnalyzer
A program to analyze misses in an osu! replay
|
|
jxnkwlp/abp-elsa-module
Elsa abp module and workflow app
|
|
usinesoft/Cachalot
Fastest transactional database for dotnet applications (classic or core); it can also be used as a high performance distributed cache
|
Version | Downloads | Last updated | |
---|---|---|---|
1.0.2 | 6,849 | 9/19/2024 | |
1.0.0 | 472,295 | 11/21/2021 | |
1.0.0-alpha.8 | 503 | 11/20/2021 | |
0.1.8-alpha.223 | 32,512 | 4/7/2021 | |
0.1.8-alpha.219 | 149 | 4/6/2021 | |
0.1.8-alpha.180 | 184 | 3/29/2021 | |
0.1.8-alpha.163 | 172 | 3/25/2021 | |
0.1.8-alpha.156 | 183 | 3/25/2021 | |
0.1.8-alpha.97 | 146 | 3/2/2021 | |
0.1.8-alpha.65 | 220 | 1/23/2021 | |
0.1.8-alpha.45 | 241 | 11/30/2020 | |
0.1.7 | 1,210,102 | 8/10/2020 | |
0.1.7-linq-expressions.50 | 263 | 7/19/2020 | |
0.1.7-alpha.68 | 295 | 7/24/2020 | |
0.1.7-alpha.66 | 252 | 7/23/2020 | |
0.1.7-alpha.64 | 284 | 7/22/2020 | |
0.1.7-alpha.61 | 289 | 7/22/2020 | |
0.1.7-alpha.57 | 271 | 7/21/2020 | |
0.1.7-alpha.52 | 247 | 7/19/2020 | |
0.1.7-alpha.37 | 354 | 7/19/2020 | |
0.1.7-alpha.24 | 239 | 7/17/2020 | |
0.1.7-alpha.17 | 272 | 7/16/2020 | |
0.1.7-alpha.15 | 281 | 7/16/2020 | |
0.1.7-alpha.9 | 334 | 7/16/2020 | |
0.1.7-alpha.5 | 277 | 7/13/2020 | |
0.1.6 | 498 | 7/9/2020 | |
0.1.6-alpha.26 | 226 | 6/29/2020 | |
0.1.6-alpha.24 | 239 | 6/29/2020 | |
0.1.5 | 838 | 6/13/2020 | |
0.1.1 | 17,578 | 1/14/2020 |