dotnet pack should pack tools with the versions that the package was built against #4063

Closed
livarcocc opened this Issue Dec 7, 2016 · 5 comments

Comments

Projects
None yet
5 participants
@livarcocc

This is for a situation where I have a library (or tool) that has a * dependency, like on Microsoft.DotNet.Cli.Utils: 1.0.0-preview4-*.

Today, the nuspec for this package gets generated with 1.0.0-preview4-, which means that when the tool gets restored, we end up with the lowest version of Cli.Utils, no matter what.

Instead, when the nuspec gets generated by pack, it should set the * versions to those in the project.assets.json file of the project being packaged.

I believe this used to be the behavior for project.json, so, in a way, we lost parity with it.

Also, we just hit this in the CLI itself and it was a bit of a pain to debug and understand all this.

cc @PiotrP @emgartem @rrelyea

@davidfowl

This comment has been minimized.

Show comment
Hide comment
@davidfowl

davidfowl Dec 7, 2016

Member

Yes that needs to work (pretty big regression otherwise)

Member

davidfowl commented Dec 7, 2016

Yes that needs to work (pretty big regression otherwise)

livarcocc added a commit to livarcocc/cli-1 that referenced this issue Dec 7, 2016

Adding a SdkNugetVersion property when invoking dotnet pack on test p…
…ackages so that test packages can reference exact packages. We need that because of NuGet/Home#4063. Without it, pack creates the nuspec with a version like 1.0.0-version-, instead of 1.0.0-version-<version_used_in_build>, which leads to problems when restoring the tool. Like, it ends up restoring to the closest version of the package (oldest), instead of the latest.

@rrelyea rrelyea added this to the 4.0 RC3 milestone Dec 8, 2016

livarcocc added a commit to livarcocc/cli-1 that referenced this issue Dec 8, 2016

Merge branch 'rel/1.0.0-preview4' into merge_preview4
* rel/1.0.0-preview4:
  Adding MigrateWebSdkRule to the DefaultMigrationRuleSet (#4963)
  MSBuild to 15.1.458 (#4950)
  Update web template for Web SDK 154 (#4948)
  Adding a SdkNugetVersion property when invoking dotnet pack on test packages so that test packages can reference exact packages. We need that because of NuGet/Home#4063. Without it, pack creates the nuspec with a version like 1.0.0-version-, instead of 1.0.0-version-<version_used_in_build>, which leads to problems when restoring the tool. Like, it ends up restoring to the closest version of the package (oldest), instead of the latest.
  remove unused directories from bundled sdks
  fix mstest package version, aligned to c#
  align f# web template
  align f# xunit template
  align f# mstest template
  align f# lib template
  align f# console proj
  bundle fsharp sdk, only Sdk directory is required
  Add more xlf files for new strings
  Updating the preview4 channel to rel-1.0.0-preview4

TheRealPiotrP added a commit to dotnet/cli that referenced this issue Dec 9, 2016

Merge rel/1.0.0-preview4 back into rel/1.0.0 (#4974)
* Updating the preview4 channel to rel-1.0.0-preview4

* Add more xlf files for new strings

* bundle fsharp sdk, only Sdk directory is required

* align f# console proj

* align f# lib template

* align f# mstest template

* align f# xunit template

* align f# web template

* fix mstest package version, aligned to c#

* remove unused directories from bundled sdks

* Adding a SdkNugetVersion property when invoking dotnet pack on test packages so that test packages can reference exact packages. We need that because of NuGet/Home#4063. Without it, pack creates the nuspec with a version like 1.0.0-version-, instead of 1.0.0-version-<version_used_in_build>, which leads to problems when restoring the tool. Like, it ends up restoring to the closest version of the package (oldest), instead of the latest.

* Update web template for Web SDK 154 (#4948)

* Update WebSDK version

* Update web template to get rid of globs

aspnet/Templates#735

* MSBuild to 15.1.458 (#4950)

* Adding MigrateWebSdkRule to the DefaultMigrationRuleSet (#4963)

* Adding MigrateWebSdkRule to the DefaultMigrationRuleSet and adding a E2E test to cover it.

* Do not migrate compile and EmbeddedResources for web application, because those are included in the Web Sdk already.

* Addressing code review comments
@natemcmaster

This comment has been minimized.

Show comment
Hide comment
@natemcmaster

natemcmaster Dec 14, 2016

Is there any way we can workaround this in RC.2 bits? If not, this will likely cause major pain while trying to upgrade aspnet to vs2017. We liberally use floating versions e.g. 1.2.0-*, but the nuspec contains 1.2.0-- on pack.

Is there any way we can workaround this in RC.2 bits? If not, this will likely cause major pain while trying to upgrade aspnet to vs2017. We liberally use floating versions e.g. 1.2.0-*, but the nuspec contains 1.2.0-- on pack.

@natemcmaster

This comment has been minimized.

Show comment
Hide comment
@natemcmaster

natemcmaster Dec 15, 2016

Workaround for RC.2: add this to your project

    <Target Name="ResolveRestoredPackageVersions"
            BeforeTargets="GenerateNuspec"
            DependsOnTargets="ResolvePackageDependenciesDesignTime"
            Condition="'$(TargetFramework)'!=''">

        <ItemGroup>
            <_FloatingVersions Include="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
            <_ResolvedFloatingVersion Include="@(_FloatingVersions)">
                <ResolvedName>%(_DependenciesDesignTime.Name)</ResolvedName>
                <Version>%(_DependenciesDesignTime.Version)</Version>
            </_ResolvedFloatingVersion>
            <_PackageReferences Remove="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
            <_PackageReferences Include="@(_ResolvedFloatingVersion)" Condition="'%(Identity)'=='%(_ResolvedFloatingVersion.ResolvedName)'" />
        </ItemGroup>
    </Target>

Workaround for RC.2: add this to your project

    <Target Name="ResolveRestoredPackageVersions"
            BeforeTargets="GenerateNuspec"
            DependsOnTargets="ResolvePackageDependenciesDesignTime"
            Condition="'$(TargetFramework)'!=''">

        <ItemGroup>
            <_FloatingVersions Include="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
            <_ResolvedFloatingVersion Include="@(_FloatingVersions)">
                <ResolvedName>%(_DependenciesDesignTime.Name)</ResolvedName>
                <Version>%(_DependenciesDesignTime.Version)</Version>
            </_ResolvedFloatingVersion>
            <_PackageReferences Remove="@(_PackageReferences)" Condition="$([System.String]::new('%(Version)').EndsWith('*'))" />
            <_PackageReferences Include="@(_ResolvedFloatingVersion)" Condition="'%(Identity)'=='%(_ResolvedFloatingVersion.ResolvedName)'" />
        </ItemGroup>
    </Target>

mlorbetske added a commit to mlorbetske/cli that referenced this issue Dec 18, 2016

Merge rel/1.0.0-preview4 back into rel/1.0.0 (#4974)
* Updating the preview4 channel to rel-1.0.0-preview4

* Add more xlf files for new strings

* bundle fsharp sdk, only Sdk directory is required

* align f# console proj

* align f# lib template

* align f# mstest template

* align f# xunit template

* align f# web template

* fix mstest package version, aligned to c#

* remove unused directories from bundled sdks

* Adding a SdkNugetVersion property when invoking dotnet pack on test packages so that test packages can reference exact packages. We need that because of NuGet/Home#4063. Without it, pack creates the nuspec with a version like 1.0.0-version-, instead of 1.0.0-version-<version_used_in_build>, which leads to problems when restoring the tool. Like, it ends up restoring to the closest version of the package (oldest), instead of the latest.

* Update web template for Web SDK 154 (#4948)

* Update WebSDK version

* Update web template to get rid of globs

aspnet/Templates#735

* MSBuild to 15.1.458 (#4950)

* Adding MigrateWebSdkRule to the DefaultMigrationRuleSet (#4963)

* Adding MigrateWebSdkRule to the DefaultMigrationRuleSet and adding a E2E test to cover it.

* Do not migrate compile and EmbeddedResources for web application, because those are included in the Web Sdk already.

* Addressing code review comments
@rrelyea

This comment has been minimized.

Show comment
Hide comment
@rrelyea

rrelyea Jan 3, 2017

Contributor

@rohit21agrawal - please get your head around this. raised as a blocking issue by asp.net team. (note there is a workaround)

Contributor

rrelyea commented Jan 3, 2017

@rohit21agrawal - please get your head around this. raised as a blocking issue by asp.net team. (note there is a workaround)

@rohit21agrawal

This comment has been minimized.

Show comment
Hide comment
@rohit21agrawal

rohit21agrawal Jan 4, 2017

Contributor

@rrelyea i already have a fix for this, this will be fixed in RC3.

Contributor

rohit21agrawal commented Jan 4, 2017

@rrelyea i already have a fix for this, this will be fixed in RC3.

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