-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix pack targets to add tfm metadata to output lib files #1255
Conversation
targetPath = Path.GetFileName(finalOutputPath); | ||
} | ||
|
||
if (string.IsNullOrEmpty(targetFramework) || NuGetFramework.Parse(targetFramework) == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think parse always returns a framework, you may want to check NuGetFramework.Parse(targetFramework).IsSpecificFramework == false
which would mean it came back as unsupported or something else that a project should not have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emgarten fixed.
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void PackCommand_PackConsoleAppWithRID_NupkgValid(bool includeSymbols) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there tests for satellite assemblies?
Returns="@(_TargetPathsToAssembliesWithTfm)"> | ||
<ItemGroup> | ||
<_TargetPathsToAssembliesWithTfm Include="@(SatelliteDllsProjectOutputGroupOutput)"> | ||
<TargetFramework>$(TargetFramework)</TargetFramework> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these have a type property? Any chance they could get mixed up later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emgarten as discussed offline, there is no need for type , as the TargetPath
metadata automatically adds culture to the filename.
|
||
if (!File.Exists(finalOutputPath)) | ||
{ | ||
throw new FileNotFoundException(string.Format(Strings.Error_FileNotFound, finalOutputPath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: set culture to current culture with string.Format, not needed with one param, but generally good to do for user facing errors.
810cfdb
to
ad296ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
bb44dc0
to
b8123cc
Compare
b8123cc
to
98c6ba1
Compare
How would 4 look in practice? I imagine that for things like .pp transforms where I'd want them to be included, I could use the existing Not sure why I'd need another set of targets? Having them as |
@onovotny yes, for anything that is not TFM specific, that would work. But once you have any content (or even build output) that is TFM specific and not covered by the default pack targets, 3 and 4 give you the flexibility to put it at the desirable location within the nuget package. While (4) is generic enough to cover the functionality of (3), (3) provides stricter control about files that need to go into the lib folder, like setting the right TFM folder names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
In Nugetizer, you simply annotate items with the kind (i.e. Lib, Build, Tools) and the right thing happens. Lib, puts the item in the TFM-specific folder according to the project's TF. If you know where you want to put it instead, you just add either TFM or a TF to the item. That's it. No additional targets, no additional properties. |
@kzu 4) is just an extension point for power users and not the default way to pack things, which we implemented because users expressed the need for it. Content is usually not TFM-specific, and that is why default targets include content only in the outer build , however, 4) provides a way for the unusual scenario of including tfm-specific content. how do you determine which items to check for the pack-specific metadata? |
@rohit21agrawal it's documented in the detail in the NuGetizer spec: https://github.com/NuGet/Home/wiki/NuGetizer-Core-Features |
Which milestone of VS will this ship with, please? |
15.3 |
Fixes: NuGet/Home#4840
Fixes: NuGet/Home#4698
Fixes: NuGet/Home#4704
This is long overdue work of adding TargetFramework metadata to build items that need to go into the lib folder in the nupkg. By adding this metadata, we know precisely where in the lib folder an item will go instead of having to search for framework in the path of the file on disk.
This change also adds outputs from SatelliteDLLsProjectOutputGroupOutput and does the appropriate plumbing so they go under their respective culture folders.
An extension point has been provided for executing custom target in the inner build for files that go in the lib (or folder specified via
BuildOutputTargetFolder
) . A user can write their own custom target and specify it as the value of the property$(TargetsForTfmSpecificBuildOutput)
. The target should write out any files that need to go into thelib
folder into the ItemGroupBuildOutputInPackage
and set the following two metadata values :a)
FinalOutputPath
: This is the absolute path of the file on disk (if not provided, the Identity is used to evaluate source path)b)
TargetPath
: This is optional and defaults to the name of the file. Users need to set it when the file needs to go into a subfolder withinlib\<TFM>
like satellite assemblies which go under their respective culture folders.An extension point has been provided for files that need to go in the nupkg outside of lib folder but are still TFM specific. A user can write their own custom target and specify it as the value of the property
$(TargetsForTfmSpecificContentInPackage)
. The target should write out any files that need to be included in the nupkg into the ItemGroupTfmSpecificPackageFile
and set the following metadata:a)
PackagePath
: Path where the file should be output in the package. NuGet will throw a warning if more than one file is added to the same package path.b)
BuildAction
: Default value has been set to None. This is only required if the package path is incontentFiles
folder.CC: @emgarten @alpaix @jainaashish @nkolev92 @rrelyea @mishra14 @zhili1208
CC: @AArnott to take a look if i covered most of his feedback in NuGet/Home#4698
CC: @onovotny for point 3 and point 4. Would appreciate any feedback on the design.