dotnet / Scaffolding

Code generators to speed up development.
MIT License
632 stars 226 forks source link

Prevent Nuget Package From Automatically Updating When Scaffolding #1343

Open davrob01 opened 4 years ago

davrob01 commented 4 years ago

Steps to reproduce:

When Microsoft.VisualStudio.Web.CodeGeneration.Design 3.1.2 is installed, add a new view or controller via Visual Studio UI (uses the scaffolding engine).

Expected behavior:

Visual Studio uses the Microsoft.VisualStudio.Web.CodeGeneration.Design 3.1.2 package currently installed.

Actual behavior:

Visual Studio automatically updates the package Microsoft.VisualStudio.Web.CodeGeneration.Design 3.1.2 to version 3.1.3

Package version of Microsoft.AspNetCore.App or Microsoft.AspNetCore.All (if applicable): 3.1.3

Package version of Microsoft.VisualStudio.Web.CodeGeneration.Design - this may be added to your project by scaffolding: 3.1.2

Hello,

Is there a way for me to have control over whether or not the nuget package Microsoft.VisualStudio.Web.CodeGeneration.Design is automatically updated (if there is an update available) when I scaffold an item? I noticed that it automatically updated today when scaffolding a new item.

My concern is that an update could - potentially - cause my custom templates to no longer get used because of MAYBE a change to how they are expected to be stored - physical directory. I would like to keep all my projects using the same version of Microsoft.VisualStudio.Web.CodeGeneration.Design for the sake of consistency if possible. This way I dont have to worry about any breaking changes. And I can update if I want to, explicitly.

Also how does Visual Studio know to update this package? Does it update whenever there is a new version or does it just try to keep the version numbers in sync with Microsoft.AspNetCore.App version?

Other Notes: I am using custom view templates at the project level in Templates\ViewGenerator_Versioned\Bootstrap3\

deepchoudhery commented 4 years ago

We try to keep them up to date since a lot users would not manually update the packages from nuget package manager for our bug fixes. However, we tend not to make any breaking changes in the minor updates so the difference between 3.1.2 and 3.1.3 is minor(mostly template updates). If anything breaks definitely open an issue here and I will help you out.

VS knows the latest version for a particular tfm over the air and forces those versions.

For the future updates, I'll try to think of a better update system that can avoid such a case.

random-pixels commented 1 year ago

Too bad this feature was never implemented. It would give us a better workaround for this issue: https://github.com/dotnet/Scaffolding/issues/2019 (Scaffolding failed. Could not load information for project) Without it, rolling back to 6.0.8 (working version) is not possible.

gtigtoxt commented 1 year ago

Pra mim não funciona de forma nenhuma, já tentei todas as soluções mas o scaffolding não funciona. bug_vs2022