Skip to content
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

Visual Studio does not have a gesture to reevaluate lock file. #10215

Open
TFTomSun opened this issue Oct 31, 2020 · 2 comments
Open

Visual Studio does not have a gesture to reevaluate lock file. #10215

TFTomSun opened this issue Oct 31, 2020 · 2 comments
Labels
Area:RestoreRepeatableBuild The lock file features Functionality:Restore Functionality:VisualStudioUI Priority:2 Issues for the current backlog. Type:DCR Design Change Request

Comments

@TFTomSun
Copy link

TFTomSun commented Oct 31, 2020

Normally, Visual Studio restores the latest package version on rebuild when you use a non-prerelease floating version ('*'). I expect the same behavior with the floating prerelease version '*-*'.

I have created demo repository with 3 projects:
https://github.com/AppGates/AppGates.Build.Versioning

It uses Nerdbank.Versioning. The ExternalLibrary is referenced as a PackageReference in the ReferencingLibrary.

steps to reproduce:

  • build the external library to get an initial local package (the pack out dir is \pack)
  • rebuild the referencing project, the external library package will be restored
  • make a change to the external library and commit it
  • rebuild the external library to generate a new package
  • rebuild the referencing project
    -> the referencing project sticks with the previous package version of the external library. The packages.lock file is not updated
@nkolev92
Copy link
Member

nkolev92 commented Nov 13, 2020

I think this is working as designed right now, but this is not ideal and something we'd like to fix.

The reason why it's not getting refreshed is because you have a lock file.

VS rebuild is not equivalent to the gesture to regenerate the lock file.

Related to #6987.

Retitling the issue to indicate the lack of a gesture to reevaluate the lock file.

Might be a good customer sprint effort, @JonDouglas @donnie-msft @zivkan

@nkolev92 nkolev92 changed the title Visual Studio doesn't restore floating prerelease versions on rebuld Visual Studio does not have a gesture to reevaluate lock file. Nov 13, 2020
@TFTomSun
Copy link
Author

I found a workaround. A bit hacky, but works.

 <!--hack to fix not working RestoreForceEvaluate property-->
  <PropertyGroup >
    <OriginalNugetLockFilePath>$(MSBuildProjectDirectory)\packages.lock.json</OriginalNugetLockFilePath>
    <NuGetLockFilePath>$(BaseIntermediateOutputPath)\packages.lock.temp</NuGetLockFilePath>
    <RestorePackagesWithLockFile>$(RestoreForceEvaluate.Equals('false').Equals(false))</RestorePackagesWithLockFile>
  </PropertyGroup>

  <Target Name="CopyTempLockFile" BeforeTargets="BeforeBuild" >
    <Move
      Condition="'$(RestoreForceEvaluate)' == 'true' AND Exists($(NuGetLockFilePath))"
      SourceFiles="$(NuGetLockFilePath)"
          DestinationFiles="$(OriginalNugetLockFilePath)"
          OverwriteReadOnlyFiles="true"/>
  </Target>

  <Target Name="RestoreBeforeClean" BeforeTargets="Clean">
    <CallTarget Targets="Restore"/>
  </Target>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreRepeatableBuild The lock file features Functionality:Restore Functionality:VisualStudioUI Priority:2 Issues for the current backlog. Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

4 participants