aspnet / Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
Other
256 stars 124 forks source link

Space in path causes migration .sql file to never be generated #940

Open Robmaister opened 7 years ago

Robmaister commented 7 years ago

Trying to do a regular deploy from VS 2015 Update 3 to Azure with a ASP.NET Core 1.1 app with EF Core Code First database. Ran into a few problems but was able to solve most of them. However, this seems to be a bug.

My user directory for an MS account on Win10 has a space in it, so the default temp path has a space in it. Everything except for these migrations seem to be handling it fine. This is the main error message I'm getting:

System.InvalidOperationException: The migration 'Rouhani\AppData\Local\Temp\PublishTemp\obj\IliumVR.Web\IliumVR.Web.SiteContext.sql' was not found.

The full path should be C:\Users\Robert Rouhani\AppData\Local\Temp\..., but I imagine some part of the publish script is mistakenly starting after the first space.

Full publish log (with some names redacted):

1>------ Build started: Project: IliumVR.Web, Configuration: Release Any CPU ------
1>  C:\Program Files\dotnet\dotnet.exe build "D:\Projects\ilium\new-website\IliumVR.Web\src\IliumVR.Web" --configuration Release --no-dependencies
1>  Project IliumVR.Web (.NETCoreApp,Version=v1.1) was previously compiled. Skipping compilation.
2>------ Publish started: Project: IliumVR.Web, Configuration: Release Any CPU ------
rmdir /S /Q "C:\Temp\IliumVR.Web\"
Environment variables:
DOTNET_CONFIGURE_AZURE=1
Path=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
C:\Program Files\dotnet\dotnet.exe publish "D:\Projects\ilium\new-website\IliumVR.Web\src\IliumVR.Web" --framework netcoreapp1.1 --output "C:\Temp\IliumVR.Web" --configuration Release --no-build
Publishing IliumVR.Web for .NETCoreApp,Version=v1.1
D:\Projects\ilium\new-website\IliumVR.Web\src\IliumVR.Web>ECHO OFF 
Bundling with configuration from D:\Projects\ilium\new-website\IliumVR.Web\src\IliumVR.Web\bundleconfig.json
Processing wwwroot/css/site.min.css
Processing wwwroot/js/site.min.js
Configuring the following project for use with IIS: 'C:\Temp\IliumVR.Web'
Updating web.config at 'C:\Temp\IliumVR.Web\web.config'
Configuring project completed successfully
publish: Published to C:\Temp\IliumVR.Web
Published 1/1 projects successfully
Publishing with publish method [MSDeploy]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error : System.InvalidOperationException: The migration 'Rouhani\AppData\Local\Temp\PublishTemp\obj\IliumVR.Web\IliumVR.Web.SiteContext.sql' was not found.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error :    at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.GenerateScript(String fromMigration, String toMigration, Boolean idempotent)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error :    at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error :    at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error :    at Microsoft.EntityFrameworkCore.Migrations.MigrationsAssemblyExtensions.GetMigrationId(IMigrationsAssembly assembly, String nameOrId)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error :    at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.ScriptMigration(String fromMigration, String toMigration, Boolean idempotent, String contextType)
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error :    at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScriptMigration.<>c__DisplayClass0_1.<.ctor>b__0()
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(408,5): Error : The migration 'Rouhani\AppData\Local\Temp\PublishTemp\obj\IliumVR.Web\IliumVR.Web.SiteContext.sql' was not found.
Executing command ["C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:manifest='C:\Users\Robert Rouhani\AppData\Local\Temp\PublishTemp\obj\IliumVR.Web\SourceManifest.xml' -dest:manifest='C:\Users\Robert Rouhani\AppData\Local\Temp\PublishTemp\obj\IliumVR.Web\DestinationManifest.xml',ComputerName='https://XXXXXXX?site=XXXXXXX',UserName='$XXXXXXXXX',Password='{PASSWORD-REMOVED-FROM-LOG}',IncludeAcls='False',AuthType='Basic' -verb:sync -enablerule:AppOffline -enableRule:DoNotDeleteRule -retryAttempts:20]
Info: Using ID 'XXXXXXXXXX' for connections to the remote server.
Info: Deleting dbFullSql (data source=tcp:XXXXXXXXXX,1433;initial catalog=XXXXXXXX;user id=XXXXXXXXXX@XXXXXXXXXXX).
Info: Using ID 'XXXXXXXXX' for connections to the remote server.
Info: Deleting dbFullSql (data source=tcp:XXXXXXXXXXXX
:XXXXXXXXXXXXXXXXX,1433;initial catalog=XXXXXXXX;user id=XXXXXXXXXXXX@XXXXXXXXX).
Info: Updating file (XXXXXXXXX\appsettings.Production.json).
Info: Updating file (XXXXXXXXX\IliumVR.Web.deps.json).
Info: Updating file (XXXXXXXXX\IliumVR.Web.runtimeconfig.json).
Info: Updating file (XXXXXXXXX\web.config).
Total changes: 6 (0 added, 2 deleted, 4 updated, 0 parameters changed, 174541 bytes copied)

2>Publish failed due to build errors. Check the error list for more details.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

I hope this is the right place for this bug report

Robmaister commented 7 years ago

Since the rest of my deployment works (spent a while verifying everything), this workaround worked for me:

  1. Change your appsettings.json connection string to the one you're trying to deploy to (grab this from Publish window -> Settings -> Databases)
  2. Open a new powershell window inside your project directory
  3. Run dotnet ef database update
  4. Change your connection string back to whatever it was before.

I tried grabbing the latest publish-module.psm1 file since that was the fix for a lot of people with "path too long" errors, but the problem is still there.

Luckily I won't be updating the model on this DB a lot, so I plan on following the above steps as part of deployment until this is fixed.

I looked into removing the space in my username, looks like it's a very involved process so I'd rather do this for now. I'll test from a machine with a username that doesn't have a space soon.

mlorbetske commented 7 years ago

TFS Bug#369169

ZombiesWithCoffee commented 7 years ago

I'm having the same issue and confirm that this is an issue.

System.InvalidOperationException: The migration 'PC\AppData\Local\Temp\PublishTemp\obj\SafeInvestigation73\SafeInvestigation.Data.ApplicationDbContext.sql' was not found.

FlorisDevreese commented 7 years ago

I have the same issue. Error : System.InvalidOperationException: The migration 'Devreese\AppData\Local\Temp\PublishTemp\obj\TodoWebApp105\TodoWebApp.Data.ApplicationDbContext.sql' was not found.