dotnet / Scaffolding

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

Identity scaffolding fails with No such file or directory #1285

Open davidbozo opened 4 years ago

davidbozo commented 4 years ago

Steps to reproduce:

Create a Web App (MVC) with Individual authentication project form the template. (I used Rider)

dotnet tool install -g dotnet-aspnet-codegenerator dotnet restore dotnet aspnet-codegenerator identity

OS: Ubuntu 18.04.4 LTS

Expected behavior:

Generate the identity scaffold.

Actual behavior:

Fails with the following output:

[Trace]: Command Line: identity
Scaffolding failed.
No such file or directory
[Trace]:    at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Microsoft.Extensions.Internal.Command.Execute()
   at Microsoft.Extensions.ProjectModel.MsBuildProjectContextBuilder.Build()
   at Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program.GetProjectInformation(String projectPath, String configuration)
   at Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program.BuildAndDispatchDependencyCommand(String[] args, String projectPath, String buildBasePath, String configuration, Boolean noBuild, ILogger logger)
   at Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program.<>c__DisplayClass19_0.<Execute>b__0()
RunTime 00:00:00.06

Additional information about the problem:

(Followed this issue: dotnet/AspNetCore.Docs#11666) I don't know is it count but if i delete the global tool and using: <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />

Output:

It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.7' was not found.
  - The following frameworks were found:
      3.1.2 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.7&arch=x64&rid=ubuntu.18.04-x64

Additional information about the project being scaffolded, such as:

Target framework(s):

netcoreapp3.1

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

I'm using the 3.1.2 SDK

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

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />

Full csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <UserSecretsId>aspnet-WebApplicationAuth-1449EA9C-6326-4DDC-9385-F30F87201553</UserSecretsId>
    </PropertyGroup>

    <ItemGroup>
        <None Update="app.db" CopyToOutputDirectory="PreserveNewest" ExcludeFromSingleFile="true" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.2" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.2" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.2" />
        <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
    </ItemGroup>

</Project>
AndreasAlapert commented 4 years ago

It also happens when trying to generate controllers.

H-a-k-a-N commented 4 years ago

I HAVE SAME PROBLEM

PS D:\Calis\MySqlTest3> dotnet ef migrations add Test It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '2.0.7' was not found.

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:

deepchoudhery commented 4 years ago

Try updating the global tool using, dotnet tool update dotnet-aspnet-codegenerator --global.

Or uninstall and reinstall if its install got messed up. Global tool and Microsoft.VisualStudio.CodeGeneration.Design version should be both 3.1.2 currently.

Try that and let me know.

Rick-Anderson commented 4 years ago

@deepchoudhery recommend closing

You can't scaffold Identity without a project. Try the following:

dotnet new webapp -au Individual -uld -o RPauth
cd RPauth
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet aspnet-codegenerator identity -dc RPauth.Data.ApplicationDbContext --files "Account.Register;Account.Register"