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

packages.lock.json reappears from deleted project after switching git branches #14015

Open
vsfeedback opened this issue Dec 20, 2024 · 0 comments

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice]
All steps are done in VS2022 17.12.3, with the available built-in tools for project edition and git operations, in 1 active session.

  1. Create a new project in an existing solution
  2. Set <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile> in the csproj
  3. Add some nuget dependencies to the project
  4. Commit / Push the new project to a new branch in the git repository
  5. Switch back to a git branch where the created project does not exist.

Switching from a branch where a project exists to a branch where the project doesn't exist reproduces the issue.

Actual result: After a build the packages.lock.json will appear despite the projet not being here. Deleting the project folder doesn't seem to fix this behavior.

Expected result: The packages.lock.json shouldn't reappear when the project disappeared in the git and solution contexts.

Workaround: Restarting Visual Studio fixes the issue.


Original Comments

Feedback Bot on 12/12/2024, 09:39 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Nigusu Yenework [MSFT] on 12/13/2024, 00:37 PM:

Thank you for reaching out. Shouldn’t the lock file be created within the folder of the new project you added? When you switch back to the other branch, wouldn’t the entire project folder (including the lock file) be expected to disappear? Could you clarify if the folder persists even after switching branches?

Why do we ask for more info?
We try to reproduce all issues reported with the information provided in the description and comments. When we can’t reproduce the issue, we ask you for more information so we can resolve the issue as quickly and efficiently as possible.
In our guidelines, you can get tips on how to provide clear and simple reproducible steps.

Matthieu Penant on 12/16/2024, 05:42 AM:

I created a repro project on github that exhibits the issue: https://github.com/Thieum/TestPackageLock

The project used to reproduce the issue is a MSTest project. Switching from test-branch to master reproduces the issue on my machine.

The commits also show the changes made for empty projects and solution.

In this situation, switching from a branch where the project exists, to the branch where it does not, does not delete the project folder entirely. A folder persists with a bin / obj folder.

The bin folder is empty, the obj folder is not.

Rebuilding logs a restore on the disapeared project and creates the lock file :

Rebuild started at 15:29…
Restored C:\Users\x\Source\Repos\TestPackageLock\TestPackageLock\TestPackageLock.csproj (in 7 ms).
1>------ Rebuild All started: Project: TestPackageLock, Configuration: Debug Any CPU ------
Restored C:\Users\x\Source\Repos\TestPackageLock\testPackageLock.Tests\testPackageLock.Tests.csproj (in 70 ms).
1>TestPackageLock -> C:\Users\thieu\Source\Repos\TestPackageLock\TestPackageLock\bin\Debug\net8.0\TestPackageLock.dll

Nikolche Kolev [MSFT] on 12/20/2024, 02:12 PM:

Matthieu Penant

thanks for the details.

I can repro this.
Likely related to how unloaded projects are supposed to work.

https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1105#visual-studio

@microsoft-github-policy-service microsoft-github-policy-service bot added Transferred issue This issue is transferred from VSFeedback or other github repo Triage:Untriaged labels Dec 20, 2024
@nkolev92 nkolev92 added Product:VS.Client Priority:2 Issues for the current backlog. Type:Bug Functionality:Restore and removed Transferred issue This issue is transferred from VSFeedback or other github repo Triage:Untriaged Priority:2 Issues for the current backlog. labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants