Skip to content

Instantly share code, notes, and snippets.

@attilah
Last active April 18, 2024 08:52
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save attilah/fd3e71f03fd258c496179e0200c57b0b to your computer and use it in GitHub Desktop.
Save attilah/fd3e71f03fd258c496179e0200c57b0b to your computer and use it in GitHub Desktop.
X.Y.Z.Sources nuget package
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<IsPackable>true</IsPackable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<NoWarn>CS8021</NoWarn>
<NoBuild>true</NoBuild>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
</PropertyGroup>
<ItemGroup>
<Compile Update="@(Compile)">
<Pack>true</Pack>
<PackagePath>$(ContentTargetFolders)\cs\netstandard1.0\$(PackageId)\%(RecursiveDir)\</PackagePath>
</Compile>
<EmbeddedResource Update="@(EmbeddedResource)">
<Pack>true</Pack>
<PackagePath>$(ContentTargetFolders)\any\any\$(PackageId)\%(RecursiveDir)\</PackagePath>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Remove="@(PackageReference)" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Target Name="Compile" />
<Target Name="CopyFilesToOutputDirectory" />
</Project>
@gitfool
Copy link

gitfool commented May 16, 2021

@kzu I switched to NuGetizer in gitfool/Cake.Dungeon@9a0080b and all the csproj black magic disappeared. ❤️

image

@kzu
Copy link

kzu commented May 17, 2021

Awesome stuff @gitfool :D

@verquepasa
Copy link

@kzu I'm using nugetizer but I'm using a sqlproj non-standard sdk that requires the files to be buildAction=content. The files are included in the nupkg and in my test project but they default to buildAction=compile. Is there a way I can force them to be content either from the nupkg or from the csproj ?
image

@kzu
Copy link

kzu commented Jun 16, 2021

Absolutely! See https://github.com/devlooped/nugetizer/blob/main/src/NuGetizer.Tasks/NuGetizer.props#L89.

You can just add the following to change that default value for all Content items:

<ItemDefinitionGroup>
  <Content>
    <BuildAction>None</BuildAction/>
  </Content>
</ItemDefinitionGroup>

@hymccord
Copy link

hymccord commented Jul 7, 2022

<PackagePath>$(ContentTargetFolders)\cs\netstandard1.0\$(PackageId)\%(RecursiveDir)\</PackagePath>

This should not end with a \. Otherwise you'll get empty folders for the root content right under the project file.

image

@kzu
Copy link

kzu commented Aug 3, 2022

@inkahootz is that nugetizer or SDK pack?

@hymccord
Copy link

hymccord commented Aug 4, 2022

@inkahootz is that nugetizer or SDK pack?

SDK pack. The code from the gist is producing that.

@MisinformedDNA
Copy link

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