0

I am trying to migrate my sln from xproj+project.json to csproj. I had on my project.json for my integration test project:

"buildOptions": {
"copyToOutput": {
  "mappings": {
    "appsettings.json": "../../src/WebApp/appsettings.json",
    "appsettings.testing.json": "../../src/WebApp/appsettings.testing.json"
  }
 }
}

when I opened the .sln with visual studio 2017 it automatically converted to:

<ItemGroup>
<None Update="..\..\src\WebApp\appsettings.testing.json">
  <Link>appsettings.testing.json</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="..\..\src\WebApp\appsettings.json">
  <Link>appsettings.json</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

but now the integration tests stopped working since it not find the appsettings.json file. it throws:

Error Message: System.IO.FileNotFoundException : The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'C:\Work\billing-app\test\IntegrationTests\bin\Debug\netcoreapp1.1\appsettings.json'.

how can I fix it so it'll continue to copy the real configuration file to the integration test project? 10x!

arielorvits
  • 5,235
  • 8
  • 36
  • 61

1 Answers1

0

the solution was to add to my web project csproj:

<ItemGroup>
<Content Update="appsettings.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

and it works.

(the mentioned lines above of integrationTest project csproj can be deleted)

arielorvits
  • 5,235
  • 8
  • 36
  • 61