I have a visual studio solution with 2 projects, both in .Net Core 3.1
Xyz.Api, Xyz.ApiTests
ApiTests is a xUnit project for integration testing.
I have followed what has been mentioned here. Integration Tests in .NET Core
This is what ApiTests.csproj looks like
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.8" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xyz.Api\Xyz.Api.csproj" />
</ItemGroup>
</Project>
I am able to run the tests from Visual Studio and it works fine.
But when I publish the ApiTests project, it doesn't create Xyz.Api.deps.json file which is required to run test using .net core cli.
This is the error I get with command "dotnet test Xyz.ApiTests.dll"
System.InvalidOperationException : Can't find'D:\T\Xyz.Api.deps.json'. This file is required for functional tests to run properly. There should be a copy of the file on your source project bin folder. If that is not the case, make sure that the property PreserveCompilationContext is set to true on your project file. E.g '<PreserveCompilationContext>true</PreserveCompilationContext>'.
I need to do this to make sure it works in Azure Pipeline.
Is there anything I am missing, or is there any other way to do this?