Refactor self contained nuget package into it's own target file

This commit is contained in:
Caelan Sayler
2024-03-14 17:20:50 +00:00
parent 542fbc97ba
commit cb9a86f0fd
5 changed files with 31 additions and 20 deletions

View File

@@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionLevel", "SolutionLe
nuget.config = nuget.config nuget.config = nuget.config
README.md = README.md README.md = README.md
Velopack.entitlements = Velopack.entitlements Velopack.entitlements = Velopack.entitlements
src\SelfContained.targets = src\SelfContained.targets
version.json = version.json version.json = version.json
EndProjectSection EndProjectSection
EndProject EndProject

View File

@@ -9,6 +9,7 @@
<OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath> <OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<BeforeTargetFrameworkInferenceTargets>$(MSBuildThisFileDirectory)SelfContained.targets</BeforeTargetFrameworkInferenceTargets>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<DebugType>embedded</DebugType> <DebugType>embedded</DebugType>

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project> <Project>
<!-- Automatically add all NuGet related properties if VelopackPackageId is set -->
<PropertyGroup Condition=" '$(VelopackPackageId)' != '' "> <PropertyGroup Condition=" '$(VelopackPackageId)' != '' ">
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance> <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright © Velopack Ltd. All rights reserved.</Copyright> <Copyright>Copyright © Velopack Ltd. All rights reserved.</Copyright>
@@ -79,5 +78,5 @@
<Exec Command='rd "$(HttpNuGetCache)" /q /s' Condition="'$(OS)' == 'Windows_NT'" /> <Exec Command='rd "$(HttpNuGetCache)" /q /s' Condition="'$(OS)' == 'Windows_NT'" />
<Exec Command='rm -rf "$(HttpNuGetCache)"' Condition="'$(OS)' != 'Windows_NT'" /> <Exec Command='rm -rf "$(HttpNuGetCache)"' Condition="'$(OS)' != 'Windows_NT'" />
</Target> </Target>
</Project> </Project>

22
src/SelfContained.targets Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup Condition=" '$(VelopackPackageSelfContained)' == 'true' ">
<!-- Include all project/package dependencies in produced NuGet package -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeTfmDependenciesInPackage</TargetsForTfmSpecificContentInPackage>
<!-- https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props?WT.mc_id=DT-MVP-5003472#copylocallockfileassemblies -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<OutputPath>$(BaseOutputPath)$(Configuration)\$(ProjectName)\</OutputPath>
</PropertyGroup>
<Target Name="IncludeTfmDependenciesInPackage">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetDir)**/*.*">
<PackagePath>build\$(TargetFramework)</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>
</Project>

View File

@@ -11,34 +11,22 @@
<PropertyGroup> <PropertyGroup>
<VelopackPackageId>Velopack.Build</VelopackPackageId> <VelopackPackageId>Velopack.Build</VelopackPackageId>
<VelopackPackageVendorLibs>true</VelopackPackageVendorLibs> <VelopackPackageVendorLibs>true</VelopackPackageVendorLibs>
<VelopackPackageSelfContained>true</VelopackPackageSelfContained>
<DevelopmentDependency>true</DevelopmentDependency> <DevelopmentDependency>true</DevelopmentDependency>
<!-- Include all project/package dependencies in produced NuGet package -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludeTfmDependenciesInPackage</TargetsForTfmSpecificContentInPackage>
<!-- https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props?WT.mc_id=DT-MVP-5003472#copylocallockfileassemblies -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Velopack.Packaging.Unix\Velopack.Packaging.Unix.csproj" PrivateAssets="all" /> <ProjectReference Include="..\Velopack.Packaging.Unix\Velopack.Packaging.Unix.csproj" />
<ProjectReference Include="..\Velopack.Packaging.Windows\Velopack.Packaging.Windows.csproj" PrivateAssets="all" /> <ProjectReference Include="..\Velopack.Packaging.Windows\Velopack.Packaging.Windows.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.9.5" PrivateAssets="all" /> <PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.9.5" />
<PackageReference Include="Riok.Mapperly" Version="3.3.0" PrivateAssets="all" /> <PackageReference Include="Riok.Mapperly" Version="3.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Velopack.Build.targets" Pack="true" PackagePath="build/Velopack.Build.targets" /> <None Include="Velopack.Build.targets" Pack="true" PackagePath="build/Velopack.Build.targets" />
</ItemGroup> </ItemGroup>
<Target Name="IncludeTfmDependenciesInPackage">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetDir)*.*">
<PackagePath>build\$(TargetFramework)</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>
</Project> </Project>