skoruba / IdentityServer4.Admin

The administration for the IdentityServer4 and Asp.Net Core Identity
MIT License
3.57k stars 1.15k forks source link

Error during migration generation in Linux based machines #710

Open shubham-vunet opened 4 years ago

shubham-vunet commented 4 years ago

Description

add-migrations Script is creating folder with forward slash in linux machines. Linux Supports file names with special characters like Colon or Forward Slash. When We are adding Migrations first migration is successful. All consequitive migrations fails. Here is the log to support the issue.

Start migrate projects
Generate migration for db provider: SqlServer , for project path -  /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer/Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer.csproj
Migrating context  IdentityServerConfigurationDbContext
Build started...
Build succeeded.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'IdentityServerConfigurationDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'IdentityServerPersistedGrantDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminIdentityDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminLogDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminAuditLogDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.SqlServer 
Done. To undo this action, use 'ef migrations remove'
Migrating context  AdminAuditLogDbContext
Build started...
Build failed.
Migrating context  AdminIdentityDbContext
Build started...
Build failed.
Migrating context  IdentityServerPersistedGrantDbContext
Build started...
Build failed.
Migrating context  IdentityServerDataProtectionDbContext
Build started...
Build failed.
Migrating context  AdminLogDbContext
Build started...
Build failed.
Generate migration for db provider: PostgreSQL , for project path -  /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.PostgreSQL/Skoruba.IdentityServer4.Admin.EntityFramework.PostgreSQL.csproj
Migrating context  IdentityServerConfigurationDbContext
Build started...
Build failed.
Migrating context  AdminAuditLogDbContext
Build started...
Build failed.
Migrating context  AdminIdentityDbContext
Build started...
Build failed.
Migrating context  IdentityServerPersistedGrantDbContext
Build started...
Build failed.
Migrating context  IdentityServerDataProtectionDbContext
Build started...
Build failed.
Migrating context  AdminLogDbContext
Build started...
Build failed.
Generate migration for db provider: MySql , for project path -  /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj
Migrating context  IdentityServerConfigurationDbContext
Build started...
Build failed.
Migrating context  AdminAuditLogDbContext
Build started...
Build failed.
Migrating context  AdminIdentityDbContext
Build started...
Build failed.

To Reproduce

Steps to reproduce the behavior: (On a linux machine)

Case 2 When Migration Folder Exists

Everything is successful but publishing and building fails. Resulting Directory looks like this. image

Updating donet ef tools
Tool 'dotnet-ef' was reinstalled with the latest stable version (version '3.1.8').
Start migrate projects
Generate migration for db provider: MySql , for project path -  /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj
Migrating context  IdentityServerPersistedGrantDbContext
Using project '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj'.
Using startup project '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj'.
Writing '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/obj/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpgSoHCr.tmp /verbosity:quiet /nologo /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj
Writing '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/obj/Skoruba.IdentityServer4.Admin.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpF6o7eu.tmp /verbosity:quiet /nologo /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj
dotnet exec --depsfile /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.deps.json --additionalprobingpath /home/s/.nuget/packages --additionalprobingpath /usr/share/dotnet/sdk/NuGetFallbackFolder --runtimeconfig /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.runtimeconfig.json /home/s/.dotnet/tools/.store/dotnet-ef/3.1.8/dotnet-ef/3.1.8/tools/netcoreapp3.1/any/tools/netcoreapp2.0/any/ef.dll migrations add DbInitTest -c IdentityServerPersistedGrantDbContext -o Migrations\IdentityServerGrants --assembly /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.dll --startup-assembly /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.dll --project-dir /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/ --language C# --working-dir /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin --verbose --root-namespace Skoruba.IdentityServer4.Admin.EntityFramework.MySql
Using assembly 'Skoruba.IdentityServer4.Admin.EntityFramework.MySql'.
Using startup assembly 'Skoruba.IdentityServer4.Admin'.
Using application base '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1'.
Using working directory '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin'.
Using root namespace 'Skoruba.IdentityServer4.Admin.EntityFramework.MySql'.
Using project directory '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'IdentityServerConfigurationDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'IdentityServerPersistedGrantDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminIdentityDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminLogDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminAuditLogDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
Using application service provider from Microsoft.Extensions.Hosting.
Found DbContext 'AdminIdentityDbContext'.
Found DbContext 'IdentityServerConfigurationDbContext'.
Found DbContext 'IdentityServerPersistedGrantDbContext'.
Found DbContext 'AdminLogDbContext'.
Found DbContext 'AdminAuditLogDbContext'.
Finding DbContext classes in the project...
Using context 'IdentityServerPersistedGrantDbContext'.
Finding design-time services for provider 'Pomelo.EntityFrameworkCore.MySql'...
Using design-time services from provider 'Pomelo.EntityFrameworkCore.MySql'.
Finding design-time services referenced by assembly 'Skoruba.IdentityServer4.Admin'.
No referenced design-time services were found.
Finding IDesignTimeServices implementations in assembly 'Skoruba.IdentityServer4.Admin'...
No design-time services were found.
Reusing namespace of type 'IdentityServerPersistedGrantDbContextModelSnapshot'.
Writing migration to '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Migrations\IdentityServerGrants/20200924070846_DbInitTest.cs'.
Writing model snapshot to '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Migrations\IdentityServerGrants/IdentityServerPersistedGrantDbContextModelSnapshot.cs'.
Done. To undo this action, use 'ef migrations remove'
Migrating context  AdminAuditLogDbContext
Using project '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj'.
Using startup project '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj'.
Writing '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/obj/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmp0cwPNE.tmp /verbosity:quiet /nologo /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.csproj
Writing '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/obj/Skoruba.IdentityServer4.Admin.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpbuqROH.tmp /verbosity:quiet /nologo /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/Skoruba.IdentityServer4.Admin.csproj
dotnet exec --depsfile /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.deps.json --additionalprobingpath /home/s/.nuget/packages --additionalprobingpath /usr/share/dotnet/sdk/NuGetFallbackFolder --runtimeconfig /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.runtimeconfig.json /home/s/.dotnet/tools/.store/dotnet-ef/3.1.8/dotnet-ef/3.1.8/tools/netcoreapp3.1/any/tools/netcoreapp2.0/any/ef.dll migrations add DbInitTest -c AdminAuditLogDbContext -o Migrations\AuditLogging --assembly /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.EntityFramework.MySql.dll --startup-assembly /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1/Skoruba.IdentityServer4.Admin.dll --project-dir /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/ --language C# --working-dir /home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin --verbose --root-namespace Skoruba.IdentityServer4.Admin.EntityFramework.MySql
Using assembly 'Skoruba.IdentityServer4.Admin.EntityFramework.MySql'.
Using startup assembly 'Skoruba.IdentityServer4.Admin'.
Using application base '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin/bin/Debug/netcoreapp3.1'.
Using working directory '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin'.
Using root namespace 'Skoruba.IdentityServer4.Admin.EntityFramework.MySql'.
Using project directory '/home/s/repos/IdentityServerAdminR1/src/Skoruba.IdentityServer4.Admin.EntityFramework.MySql/'.
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'IdentityServerConfigurationDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'IdentityServerPersistedGrantDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminIdentityDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminLogDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.8 initialized 'AdminAuditLogDbContext' using provider 'Pomelo.EntityFrameworkCore.MySql' with options: MigrationsAssembly=Skoruba.IdentityServer4.Admin.EntityFramework.MySql ServerVersion 5.7 MySql 
Using application service provider from Microsoft.Extensions.Hosting.
Found DbContext 'AdminIdentityDbContext'.
Found DbContext 'IdentityServerConfigurationDbContext'.
Found DbContext 'IdentityServerPersistedGrantDbContext'.
shubham-vunet commented 4 years ago

I tried replacing Backwards Slash () with Forward Slash(/) in build/add-migrations.ps1 . It worked in both Linux and Windows. Sorry I can't test on mac.

Updated code looks like this.

#Initialze db context and define the target directory
$targetContexts = @{ 
    AdminIdentityDbContext                = "Migrations\Identity"
    AdminLogDbContext                     = "Migrations\Logging";
    IdentityServerConfigurationDbContext  = "Migrations\IdentityServerConfiguration";
    IdentityServerPersistedGrantDbContext = "Migrations\IdentityServerGrants";
    AdminAuditLogDbContext                = "Migrations\AuditLogging";
    IdentityServerDataProtectionDbContext = "Migrations\DataProtection";
}

I can create a PR after reviewing other scripts.

skoruba commented 4 years ago

@cossth - thank you for reporting this issue on linux