-
-
Save attilah/fd3e71f03fd258c496179e0200c57b0b to your computer and use it in GitHub Desktop.
| <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> |
Hello,
Thank you for that great example and medium article.
I tried to use it but I experienced some issues when using it in an WPF environment.
As soon as anUserControlis added to the Project, the compailer cant find the nuget imported c# files.I created that sample project to demonstrate the problem.
Can anyone help here? ;) Thank you!
I could find a fix for the problem.
You have to add
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>to your WPF project.
@kzu I switched to NuGetizer in gitfool/Cake.Dungeon@9a0080b and all the csproj black magic disappeared. ❤️
Awesome stuff @gitfool :D
@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 ?

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>@inkahootz is that nugetizer or SDK pack?
@inkahootz is that nugetizer or SDK pack?
SDK pack. The code from the gist is producing that.
Gist explanation: https://medium.com/@attilah/source-code-only-nuget-packages-8f34a8fb4738


Oh, absolutely.
The above sample would look like the following:
And given a couple .cs and a .resx, you'd get a package with the following content after running
dotnet restorefollowed bydotnet pack:(the output is from the
dotnet-nugetizeglobal tool, which can be run simply withnugetizeon the project directory).The actual console output looks way nicer though ;)
It makes it very easy to quickly iterate on the packaging structure without ever having to build or even pack/zip files.
If you wanted the .resx to also be provided only for the cs code language you just update those appropriately: