-
Notifications
You must be signed in to change notification settings - Fork 359
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
Reject multiple versions of same package #15367
base: main
Are you sure you want to change the base?
Reject multiple versions of same package #15367
Conversation
@@ -123,6 +123,7 @@ | |||
|
|||
<ItemGroup> | |||
<IntermediateNupkgFile Include="@(IntermediateNupkgArtifactFile)" PackagePath="artifacts" /> | |||
<IntermediateNupkgFile Remove="@(IntermediateNupkgFile)" Condition="'$(Version)' != '' and !$([System.Text.RegularExpressions.Regex]::Match(%(Identity),'$(Version)').Success)"/> |
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 you just want to generate an error if you find multiple packages with the same ID in the input package set.
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.
Sure, I have updated the code d6772cd, an error will be generated if I find the packages with multiple versions and will provide the package path.
@@ -129,6 +129,15 @@ | |||
<Output TaskParameter="Filtered" ItemName="IntermediatePackageFile" /> | |||
</RemoveDuplicates> | |||
|
|||
<ItemGroup> | |||
<IntermediateFileWithoutVersion Include="$([System.Text.RegularExpressions.Regex]::Replace('%(IntermediatePackageFile.Identity)','\.(\d+\.){2}\d+(-\w+)?(\.(\d+\.){1}\d+)?',''))" /> |
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 this can be simpler. nupkgs are always of the form .version.nupkg, so I don't think you need to use the more fragile regex match here.
In addition, I would strip the versions, then call RemoveDuplicates, then check that IntermediateNupkgFile's count matches IntermediateFileWithoutVersion's count
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 this can be simpler. nupkgs are always of the form .version.nupkg, so I don't think you need to use the more fragile regex match here.
For example, in the roslyn
repo, the paths of the packaged .nupkgs are all $(ArtifactsPackagesDir)Shipping
and $(ArtifactsPackagesDir)NonShipping
, and the version format all matches $(Version)
, so I can simply strip the versions with $(Version)
. But according to the information you gave to me, 3 versions of the same package will be created via the PackageReleasePackages
target, the versions are not in the same format, so I used the regex replace to strip the versions.
Version | Format | Path |
---|---|---|
Release stable version | 1.0.0 | $(ArtifactsPackagesDir)Release |
PreRelease stable version | 1.0.0-preview | $(ArtifactsPackagesDir)PreRelease |
Non-stable version | 1.0.0-preview.1234.5 | $(ArtifactsShippingPackagesDir) |
then call RemoveDuplicates, then check that IntermediateNupkgFile's count matches IntermediateFileWithoutVersion's count
This method is indeed simpler, but it may not provide information about the .nupkg.
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.
Hi @mmitche , does the above explanation make sense to you? Or do I still need to modify the code according to your previous suggestions?
Related: dotnet/source-build#3391
Add a condition to check whether the package versions are consistent and remove other versions of the same package.