question

bhanu-prakash-thunuguntla avatar image
0 Votes"
bhanu-prakash-thunuguntla asked SanjayRajkumar-7974 published

deps.json not published for projects referenced for XUnit Integration Tests project.

I have a visual studio solution with two projects, both are using .NET Core 3.1

  1. Xyz.Api

  2. Xyz.ApiTests

ApiTests is a XUnit project for integration testing and has a PROJECT REFERENCE to Xyz.Api project

I have followed what is mentioned here. Integration Tests in .NET Core

This is what ApiTests.csproj looks like.

 <Project Sdk="Microsoft.NET.Sdk.Web">
    
   <PropertyGroup>
     <TargetFramework>netcoreapp3.1</TargetFramework>
     <IsPackable>false</IsPackable>
   </PropertyGroup>
    
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.10" />
     <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.10" />
     <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.10" />
     <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.10" />
     <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.10" />
     <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.1.10" />
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
     <PackageReference Include="Moq" Version="4.14.7" />
     <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
     <PackageReference Include="xunit" Version="2.4.1" />
     <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
     </PackageReference>
     <PackageReference Include="coverlet.collector" Version="1.3.0">
       <PrivateAssets>all</PrivateAssets>
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
     </PackageReference>
   </ItemGroup>
    
   <ItemGroup>
     <ProjectReference Include="..\..\Xyz.Api\Xyz.Api.csproj" />
   </ItemGroup>
    
   <ItemGroup>
     <None Update="appsettings.json">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
   </ItemGroup>
    
 </Project>


Iam able to run the XUnit integration tests using Visual Studio.
On Release build, the bin folder has both files - Xyz.Api.deps.json and Xyz.ApiTests.deps.json

But on Publish, the PUBLISH folder has only one file - Xyz.ApiTests.deps.json; and the Xyz.Api.deps.json file is missing.

When I run dotnet test Xyz.ApiTests from PUBLISH folder, Iam getting the following error.

Can't find'D:......\Xyz.ApiTests\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>'. For functional tests to work they need to either run from the build output folder or the ReleaseManagement.Api.deps.json file from your application's output directory must be copied to the folder where the tests are running on. A common cause for this error is having shadow copying enabled when the tests run.

How to make sure the file Xyz.Api.deps.json is also copied to PUBLISH folder on PUBLISH PROJECT?
Any help please?





dotnet-csharpdotnet-aspnet-core-generaldotnet-runtime
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

the PUBLISH folder has only one file - Xyz.ApiTests.deps.json; and the Xyz.Api.deps.json file is missing. Hi @bhanu-prakash-thunuguntla, how do you publish the project, using CLI command?

0 Votes 0 ·

I published in two places.

  1. In my local machine, right click on ApiTests project and PUBLISH

  2. Second place, in Azure DevOps CI Pipeline - using DotNetCoreCLI@2 task with command "publish"

By the way, I also have xunit.runner.json file with shadowcopy:false in the ApiTests project.



0 Votes 0 ·
FeiHan-MSFT avatar image FeiHan-MSFT bhanu-prakash-thunuguntla ·

Can you share the code of Xyz.Api.csproj? Then I can help check if something wrong with it.

0 Votes 0 ·
Show more comments
bhanu-prakash-thunuguntla avatar image
0 Votes"
bhanu-prakash-thunuguntla answered

Xyz.Api.csproj file content is here.

 Xyz.Api.csproj file content is here.
    
    
     <Project Sdk="Microsoft.NET.Sdk.Web">
        
       <PropertyGroup>
         <TargetFramework>netcoreapp3.1</TargetFramework>
         <UserSecretsId>a0979ad4-2dd4-46cf-9433-eb5f5de4da3d</UserSecretsId>
         <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
         <DockerfileContext>..\..</DockerfileContext>
       </PropertyGroup>
         <PropertyGroup>
             <LangVersion>latest</LangVersion>
         </PropertyGroup>
       <ItemGroup>
         <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
         <PackageReference Include="MediatR" Version="9.0.0" />
         <PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
         <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.15.0" />
         <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.2" />
         <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes.HostingStartup" Version="1.1.2" />
         <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.1.8" />
         <PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureKeyVault" Version="3.1.8" />
         <PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="3.1.8" />
         <PackageReference Include="Microsoft.AspNetCore.Diagnostics.HealthChecks" Version="2.2.0" />
         <PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.0.0" />
         <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.8" />
         <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.8">
           <PrivateAssets>all</PrivateAssets>
           <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
         </PackageReference>
         <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.8" />
         <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.8" />
         <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
         <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
         <PackageReference Include="MongoDB.Driver" Version="2.11.2" />
         <PackageReference Include="Polly" Version="7.2.1" />
         <PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
         <PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.1.0" />
         <PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
         <PackageReference Include="System.Collections" Version="4.3.0" />
         <PackageReference Include="System.Runtime" Version="4.3.1" />
       </ItemGroup>
       <ItemGroup>
         <ProjectReference Include="..\ReleaseManagement.Deployment\ReleaseManagement.Deployment.csproj" />
         <ProjectReference Include="..\ReleaseManagement.DevOps.Client\ReleaseManagement.DevOps.Client.csproj" />
       </ItemGroup>
    
     </Project>
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SanjayRajkumar-7974 avatar image
0 Votes"
SanjayRajkumar-7974 answered SanjayRajkumar-7974 published

Hi,

I am also facing same problem , did you got this working ?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.