dotnet / Scaffolding

Code generators to speed up development.
MIT License
641 stars 229 forks source link

Scaffolding fails with Central Package Managment (Microsoft.Build.CentralPackageVersions) #1672

Open FreeApophis opened 3 years ago

FreeApophis commented 3 years ago

File a bug

Visual Studio 2022

Add / View / Razor View / ...

When scaffolding it shows "updating the dependency information" which then fails accordingliy with this error:

1>C:\Repositories\MinimalApi\MinimalApi\Apophis.csproj  : error : The package reference 'Microsoft.VisualStudio.Web.CodeGeneration.Design' should not specify a version.  Please specify the version in 'C:\Repositories\MinimalApi\Packages.props' or set VersionOverride to override the centrally defined version.

Include your code

<Project Sdk="Microsoft.NET.Sdk.Web; Microsoft.Build.CentralPackageVersions">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" />
  </ItemGroup>
</Project>

It always changes the version part back to the failing PackageReference

    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0-rc.2.21511.1" />

version information

This happens with all preview version I tried, I did not try with VS2019 or .NET 5

Rick-Anderson commented 2 years ago

You have to manually add it. In VS2022 PM

Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

Can you close this issue? It works fine in the released version other than making you install it manually.