Skip to content

dotnet pack creates odd dates in package using version 3.0.100-preview9-014004 #3388

Closed

Description

@phillipsj

dotnet pack creates odd dates in package using version 3.0.100-preview9-014004

After switching to the version listed above our nuget packages started having very strange dates. The first date that is being displayed is inside of the nuget packages before being unpacked. The date is 12/29/1899.

image

Once we unpack the package, the date changes to 12/29/1979.

image

This only started occuring after we upgrade from 3.0.100-preview7-012821 to 3.0.100-preview9-014004.

Activity

  1. Macromullet commented on Sep 17, 2019

    @Macromullet

    I have confirmed this issue persists in RC1

  2. livarcocc commented on Sep 17, 2019

    @livarcocc
  3. Macromullet commented on Sep 17, 2019

    @Macromullet
  4. Macromullet commented on Sep 17, 2019

    @Macromullet

    Just confirmed using
    dotnet pack -p:Deterministic=false
    serves as a workaround, but it's odd that the default is to enable deterministic builds.

  5. DamianEdwards commented on Sep 17, 2019

    @DamianEdwards
    Member

    I reproduced the behavior locally on one of my existing projects too.

  6. nkolev92 commented on Sep 17, 2019

    @nkolev92
    Contributor

    The deterministic property is set in the project itself.

    The compiler respects the <Deterministic>true</Deterministic> property, and starting with 3.0 so does NuGet at pack time.

    https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#deterministic

    1980 was chosen as the min zip supported date.

    The reason behind that if the customer wants deterministic binaries at build time, having deterministic packages is important too.

    As @Macromullet linked NuGet/Home#6229 contains the reasoning.
    Spec at https://github.com/NuGet/Client.Engineering/blob/master/Specs/Deterministic-Pack.md

  7. phillipsj commented on Sep 17, 2019

    @phillipsj
    Author

    @nkolev92 we don't have that property set at all in our project. Why would it default to being enabled?

  8. phillipsj commented on Sep 17, 2019

    @phillipsj
    Author

    So it is set to true by default? That is a huge change IMO to make it default to true. Since it defaults to an older date we have packages that are not getting updated on deployment of our web app because of how deployment tools like web deploy uses the dates.

  9. nkolev92 commented on Sep 17, 2019

    @nkolev92
    Contributor

    @phillipsj

    How are you deploying? What's the tooling used for deployment purposes?

    //cc @tmat

  10. Macromullet commented on Sep 17, 2019

    @Macromullet

    I echo Jamie's sentiments. The change is sensible, but breaking, and I'm not sure customers have been made fully aware of how this changes deployments in Azure. I did find that prop, and did notice that it was set to true by default, which is why I commented on it. Windows and many other deployment systems use modified time as a way to know what should be overwritten. If you don't know what's newer (if it's an alpha or beta binary and you're using semantic versioning, then then major.minor.build may not increase).

  11. phillipsj commented on Sep 17, 2019

    @phillipsj
    Author

    @nkolev92 we are packing with Azure DevOps using the SDK.

  12. rrelyea commented on Sep 17, 2019

    @rrelyea

    @Macromullet @phillipsj - @nkolev92 is asking about the "tooling used for deployment purposes" so we can understand more details when @phillipsj said:

    Since it defaults to an older date we have packages that are not getting updated on deployment of our web app because of how deployment tools like web deploy uses the dates.

    What are repro steps that show that this is a significant problem?

  13. DamianEdwards commented on Sep 17, 2019

    @DamianEdwards
    Member

    @phillipsj where does it go after that? I can see how this will effect deployments where assets are moved through a pipeline as a NuGet package, and then expanded out in another step and treated as loose files again, because their dates will now be fixed.

  14. DamianEdwards commented on Sep 17, 2019

    @DamianEdwards
    Member

    Hypothetical example of a build pipeline that will be broken by this:

    1. Build a csproj into a nupkg and mark the nupkg as the stage output
    2. Take the previous stage output and put it on a feed
    3. Download the latest version of the package from the feed
    4. Expand the package and then run a copy to a different target output (e.g. folder) based on file timestamps so you only copy what's newer

    In this situation, you'll never get the new copies of the files as they went through a format that doesn't ever update the timestamps of the contents.

  15. 18 remaining items

  16. nkolev92 commented on Sep 18, 2019

    @nkolev92
    Contributor

    @Macromullet

    My assumption was that having different timestamps in the zip would affect the zip bytes (since the timestamps are encoded in the bytes that the zip represents), so that if you were to keep the timestamps, then the same build/pack scenario would lead to a different byte stream representation, thereby making it non-deterministic. I assumed that's why the change was made in the first place.

    My suggestion was no timestamps in the zip :)
    Then at extract time, the timestamps will be set to now.

  17. Macromullet commented on Sep 18, 2019

    @Macromullet

    @Macromullet

    My assumption was that having different timestamps in the zip would affect the zip bytes (since the timestamps are encoded in the bytes that the zip represents), so that if you were to keep the timestamps, then the same build/pack scenario would lead to a different byte stream representation, thereby making it non-deterministic. I assumed that's why the change was made in the first place.

    I was suggestion, no timestamps in the zip :)
    Then at extract time, the timestamps will be set to now.

    OK that makes more sense, but I feel that leads to ancillary issues, namely that you cannot know when anything in a nuget file was built. Maybe the argument is that you shouldn't, but all tooling up to this point has worked under the assumption that when those files come out, the date is useful. If you were to set the date on unpack, for one you'll have to push those files on every deploy, since the timestamp will always be new. Worse, if you put in a replacement file on the server that's newer manually, then redeploy (i'm not suggesting this is a good idea), then it would always overwrite it. It violates common publishing semantics.

  18. nkolev92 commented on Sep 18, 2019

    @nkolev92
    Contributor

    namely that you cannot know when anything in a nuget file was built.

    Which at its core is counter to determinism.

    We'll definitely factor in that input into our future work for pack determinism.

  19. phillipsj commented on Sep 18, 2019

    @phillipsj
    Author
  20. phillipsj commented on Sep 18, 2019

    @phillipsj
    Author

    BTW, I would like it if we can ignore timestamps, unfortunately, legacy is catching us on this.

  21. tmat commented on Sep 18, 2019

    @tmat
    Member

    @phillipsj Making the timestamp settable just shifts the problem elsewhere but it does not address the problem.

    I think what NuGet pack could do is to calculate the timestamp based on the NuGet package version. That would make it monotonically increasing for release packages. Pre-release packages that do not differ in the 3-part number would still get the same timestamp. Would that be ok?

    In any case I think the deployment systems still need to be updated to stop relying on timestamps.

  22. phillipsj commented on Sep 18, 2019

    @phillipsj
    Author

    @tmat That is a reasonable solution too.

  23. nguerrera commented on Sep 18, 2019

    @nguerrera
    Contributor

    I am very unfamiliar with these deployment technologies, but naively, I don't actually understand why you would ever want to deploy based on newer timestamp or newer versions. If I downgrade a package reference due to a bug that broke my app, shouldn't it deploy the older binaries from my newer source?

  24. Macromullet commented on Sep 18, 2019

    @Macromullet

    I think a potential mitigating factor is that the deployment technologies can be diverse. We are using webdeploy in some places, but In others we favored Run From Package, primarily to avoid locking, but the atomicity perks were also helpful. I’m wondering if this is even an issue for that given its behavior.

    For thick client apps most people use MSI, and things certainly get worse there. Major/Minor/Revision are the only things that are counted as I recall with a tiebreaker on modified time. This certainly throws some of that out of whack.

  25. nkolev92 commented on Sep 19, 2019

    @nkolev92
    Contributor

    We have disabled the deterministic pack feature in the GA .NET Core version.

    NuGet/Home#8601 is the issue to follow for further pack + determinism updates.

    edit
    I guess this issue can be closed now?

  26. scalablecory commented on Sep 23, 2019

    @scalablecory
    Contributor

    Closing issue, it appears it was resolved in Nuget.

  27. zivkan commented on Dec 3, 2025

    @zivkan
    Member

    If anyone who was affected in 2019 by this change is still watching this issue, there's renewed interest in bringing it back. A few weeks or months ago I tried to reproduce the problem this issue discusses, but I was unable to find a scenario where msdeploy to azure would fail to deploy dlls with the same or older timstamps.

    Anyway, I'd appriciate your input, because so far this other thread only has commenters saying that determinisitic pack should be re-enabled: NuGet/Home#8601 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions