Efcore: Absolute path in OutputPath breaks Add-Migration

Created on 23 Apr 2018  路  15Comments  路  Source: dotnet/efcore

I created a netcoreapp2.0 project from VS template and changed the output path <OutputPath> to be an absolute path. I use this (along with other MSBuild properties) on my devbox to separate where my source lives and where my intermediate and output directories are. This is useful for me since I want Dropbox syncing my code by not my binaries.

Minimal repro .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <OutputPath>D:\Dropbox\Programming\Repro\Repro\bin\$(Configuration)</OutputPath>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0-preview2-final" />
  </ItemGroup>

</Project>

I have tried older versions of the Tools package. The Program.cs doesn't even matter since it seems like Add-Migration can't even find the output assembly.

VS version: 15.6.4
NuGet version: 4.6.1.5019

closed-fixed type-bug

Most helpful comment

Workaround

Comment out the OutputPath, add the migration, uncomment out the OutputPath, then delete the bin directory.

All 15 comments

Workaround

Comment out the OutputPath, add the migration, uncomment out the OutputPath, then delete the bin directory.

<OutputPath> should be relative. (See Common MSBuild Project Properties.) Instead, set <BaseOutputPath>:

<BaseOutputPath>D:\Dropbox\Programming\Repro\Repro\bin\</BaseOutputPath>

But we can probably fix this simply by using [IO.Path]::Combine() instead of Join-Path.

D'oh! I didn't realized that. I'll give it a try. Strange that everything else in VS seems to work okay with an absolute path there (or maybe I am missing something).

I've tried that too can got a similar error:

Project:

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <BaseOutputPath>D:\Dropbox\Programming\Repro\Repro\bin\</BaseOutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0-preview2-final" />
  </ItemGroup>

</Project>

Error:
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot find path 'D:\Dropbox\Programming\Repro\Repro\D:\Dropbox\Programming\Repro\Repro\bin\Debug\netcoreapp2.0\' because it does not exist.

Definitely a bug then. As a workaround, you should be able to use the dotnet ef commands instead.

Okay, thanks for the milestone, @ajcvickers. Looking forward to the fix!

I am using .NET Framework, non-SDK based project so I don't think I can use dotnet ef right?

Also, I when I originally found this my output directory was a different drive than my source (D:\ and C:\, respectively). I humbly suggest that this is a test case included in the bug fix.

I am using .NET Framework, non-SDK based project so I don't think I can use dotnet ef right?

Right, it wouldn't work.

PM> add-migration passport
The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot find path 'C:\Usersdima\source\repos\TNPK\TNPK\M:\Build\TNPK\net461\win7-x64\' because it does not exist.

VS 15.7.3 kinda stuff

Hello, I'm able to reproduce this issue with the following sample project:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <BaseOutputPath>c:/dev/ReproProject/TestOutput</BaseOutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
  </ItemGroup>

</Project>

Running add-migration InitialMigration yields the following error:
Command execution stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot find path 'C:\dev\blue\main\AirspaceSimulationPlugin\Inexa.Control.Airspace.Simulation.Web.Service\C:\dev\blue\main\AirspaceSimulationPlugin\output\Inexa.Control.Airspace.Simulation.Web.Service\bin\Debug\netcoreapp2.1\' because it does not exist.

I'm guessing line 761 in EntityFrameworkCore.psm1 or around there may be the issue?

@gusmally This issue is fixed in EF Core 2.2.

@ajcvickers Hello...is there any workaround for EFCore 2.1? I am forced from my project dependencies to use that version but this issue is giving me problems. Thanks

@angieleba There are several workarounds discussed in the comments above. Have you tried these?

@ajcvickers Yes, commenting the paths, adding migration and than un-commenting to build, worked.

I am having a similar issue with .NET Core 3.1. However looking at the project file there is not output path defined. This happened with a new project created using VS 8.6.3 for Mac. I've read as well about a similar issue reported but to the VS team (marked as already fixed). So after finding this thread I don't know if it is a VS issue or a EF Core one.

Was this page helpful?
0 / 5 - 0 ratings