Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
NuGet pack "The DateTimeOffset specified cannot be converted into a Zip file timestamp" #3793
NuGet pack "The DateTimeOffset specified cannot be converted into a Zip file timestamp" #3793
Changes from 8 commits
1e0437f
57bb207
e45b889
d7bdb3c
18e3bf0
3f11fc4
5c9d833
ede2569
d89fcfb
b212126
146d4e5
7442f7b
dea0eef
bd1c76a
d9e5479
f24aff3
af38361
69161ae
a7f53aa
c5c3ebf
49cc7eb
5d812dc
b7737cb
fa51fa0
9bad83e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Why log only once?
We should log for all files that were adjusted.
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.
Because of this comment to limit spamming.
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.
The method
WriteFiles
iterates the files in the package and callsCreatePart
for each. If you create a collection in this method, containing all the filenames with "out of range" dates in this method, then you can create a single message with all the affected files. As an example, see this pack validation ruleThere 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 agree with @zivkan
Limit spamming means omitting repetitive information.
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.
Ok. I imitated your pattern but end result seems still same.
Currently
dotnet.exe pack --no-build
output looks like below:Can you elaborate more on removing repetitive information? Is below looks correct approach? But this one has some complexities. Instead of
is
we need to useare
, so we need need to have another string resource specific for purpose. Also how about someone mix 1956 and 2200 files then what message to show (not sure if it's possible scenario)?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.
Other warnings had a block of text, followed by a list of shorter messages for each individual instance. So, you could think about changing the warning to something like:
This way we can avoid repeating the "out of range for what the zip format supports" text.
Also, if you were to do this in Visual Studio, you should see only a single entry in the error list, not one per file. I'm not sure if it reduces a list of warnings in a binlong.
Having said this, I was thinking about it over the weekend, and I'm feeling much less strongly about this. Consider a c# syntax error instead. If I have the same syntax error in multiple places in a single file, Roslyn is going to raise one warning per instance, not one warning per file or one warning per project. One difference is that in Visual Studio you can click the warning and go to the line of code, whereas NuGet doesn't. Even if NuGet had the capability to determine a filename and line number, for "go to error" in general, I'm not sure it makes sense for this specific warning. It probably makes sense here to have a single message with a list of affected files.
As mentioned in another comment, we should have an NU warning code, and a docs issue to document the NU code.
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 my previous round of reviews, I asked to make sure
timeOffset
was in the UTC timezone before settingentry.LastWriteTime
, but I don't see that it's checked or converted anywhere.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.
Just in case I added
.UtcDateTime
. But for actual physical files it's already in UTC timezone and it comes from below call stack.This method calls our above method and passing
lastWriteTime
.NuGet.Client/src/NuGet.Core/NuGet.Packaging/PackageCreation/Authoring/PackageBuilder.cs
Line 1126 in 49cc7eb
And this one calls above 1 and passing
lastWriteTime
.NuGet.Client/src/NuGet.Core/NuGet.Packaging/PackageCreation/Authoring/PackageBuilder.cs
Lines 966 to 970 in 49cc7eb
In non-deterministic mode
lastWriteTime
isfile.LastWriteTime
which actually reads UTC datetime here:NuGet.Client/src/NuGet.Core/NuGet.Packaging/PackageCreation/Authoring/PhysicalPackageFile.cs
Lines 96 to 99 in 74781ba
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.
Yes, but
NuGet.Packaging
is a package that customers can reference in their own projects, and by implementing their ownIPackageFile
that does not return UTC time, they could encounter problems. You've fixed it by using.UtcDateTime
, but my point is that since NuGet is not only a tool, but also a package/SDK, we need to consider all the different possible usage.Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.