-
Describe the BugAppendTargetFrameworkToOutputPath not respected by PackageFile target, such that the output from
Steps to ReproduceI don't know how to provide a unit test for MSBuild related stuff. <?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<!-- ReSharper disable UnknownProperty -->
<PropertyGroup>
<Authors>John Zabroski</Authors>
<Copyright>Simmaculate</Copyright>
<TargetFramework>net5.0</TargetFramework> <!--netcoreapp2.1, netcoreapp3.1 also supported -->
<EnablePackInference>false</EnablePackInference>
<PackageIcon>icon.png</PackageIcon>
<PackageId>Custom</PackageId>
<AssemblyTitle>Custom Packaging</AssemblyTitle>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin</OutputPath>
</PropertyGroup>
<PropertyGroup>
<PackDependencies>true</PackDependencies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nugetizer" Version="*" />
<PackageReference Include="ThirdParty.OData" Version="*" >
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageFile Include="ThirdParty.OData" Version="*" PackFolder="Content" Pack="true" />
</ItemGroup>
</Project> Expected BehaviorBased on AppendTargetFrameworkToOutputPath=false and PackDependencies=true and OutputPath=bin, I would expect the third party nuget package to be transcluded into the bin folder, and the /any/net5.0 sub-tree to be deforested so that its just "/contentFiles/". Exception with Stack Tracen/a Version Infodotnet-nugetize 0.7, Nugetizer 0.7 Additional InfoI figured I would use this prototype as research into @kzu suggesting I give Nugetizer a try to solve problems with SDK Pack, but so far I am not fully wrapping my head around how this is supposed to work, and I am most definitely not an MSBuild or Nuget expert. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 7 replies
-
Changing <ItemGroup>
<PackageFile Include="ThirdParty.OData" Version="*" PackFolder="Content" Pack="true" />
</ItemGroup> to: <ItemGroup>
<PackageFile Include="ThirdParty.OData" Version="*" PackFolder="Content" Pack="true" FrameworkSpecific="false" />
</ItemGroup> Generates the following instead:
Not exactly what I was expecting. |
Beta Was this translation helpful? Give feedback.
-
If you want to precisely control target location, use PackagePath metadata instead. PackFolder applies default heuristics according to the folder default behavior, like what you're seeing. Content/ContentFiles in particular, has specific rules outlined in the nuget docs. |
Beta Was this translation helpful? Give feedback.
-
I did find PackagePath but I am not sure I understand how to properly use it. Can you point me to the nuget docs that have the specific rules for Content/ContentFiles? In the SDK Pack world, all I have to know about is whether an item is Content or not, so I am not familiar with specific rules, as I am guessing SDK Pack hides them from me? I think my confusion comes from trying to follow this example on your blog post: <!-- Add package dependencies directly too -->
<PackageFile Include="Newtonsoft.Json" Version="13.0.1" PackFolder="Dependency" /> I didn't realize that what you were implying is I could avoid nuget restore entirely by simply forcing the dependency information. I thought PackageFile Include="Newtonsoft.Json" might somehow automagically download the package and provide us with the option to include all packagereferences in a single package, similar to what Cake and OctoPack do. |
Beta Was this translation helpful? Give feedback.
-
https://devblogs.microsoft.com/nuget/nuget-contentfiles-demystified/ |
Beta Was this translation helpful? Give feedback.
-
OK, I read that, but the behaviors I am seeing still seem broken to me. Here is an example. I have a hand-written <?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>$Id$</id>
<version>$Version$</version>
<description>$Description$</description>
<authors>$Authors$</authors>
<copyright>$Copyright$</copyright>
</metadata>
<files>
<file src="bin\release\**\*" target="" />
<file src="*.config" />
<file src="*.xml" />
</files>
</package> When I write the following Nugetizer MSBuild XML, why does it create any/any subdirectories, even when I explicitly forget the target to be ""? What is the Nugetizer PackageFile equivalent for my Note, I have:
It seems like there is no way to disable the generation of contentFiles/any/any (although, I do recall yesterday somehow doing it, I cant seem to replicate that success today, and I didnt commit my work yesterday and blew it all away to start over). |
Beta Was this translation helpful? Give feedback.
-
It also looks like ContentTargetFolders isn't respected. Not sure if it should be. Mostly just going off the description that Nugetizer is mostly a drop-in replacement for "SDK Pack". Seems like a reasonable expectation it should, based on https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#including-content-in-a-package |
Beta Was this translation helpful? Give feedback.
-
Plz provide the csproj with the content laid out by SDK Pack and how nugetizer differs from that. (after just referencing nugetizer, no csproj changes, aka "drop in replacement" :)) Thanks! |
Beta Was this translation helpful? Give feedback.
-
Also, perhaps change the issue title since |
Beta Was this translation helpful? Give feedback.
-
Converted to discussion since it's not clear there's a bug yet that can be worked on. Thanks! |
Beta Was this translation helpful? Give feedback.
Also, perhaps change the issue title since
AppendTargetFrameworkToOutputPath
doesn't play a role in SDK pack or nugetizer alike? (to the best of my knowledge, at least)