0

In another languages, when a build for production is performed, there are configurations to avoid libraries or dependencies not related to the build like: unit test, code coverage, etc

nodes js

npm install --production

java

<dependency>...<scope>test</scope>...</dependency>
mvn clean package

So my question is:

How to skip unit test libraries download on production build using c# and dotnet?

Unsuccessful attempts

Workaround

To have 02 different *.csproj

  • src/Api.csproj with required runtime dependencies
  • test/Api.Test.csproj with only unit test dependencies

This is a problem because I cannot set the csproj for testing when I run custom tasks

dotnet msbuild  -target:DisplayMessages --project test/Api.Test.csproj
JRichardsz
  • 14,356
  • 6
  • 59
  • 94
  • The workaround you mention of having separate test projects is the standard way of doing testing in .NET as outlined in the examples by microsoft https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-with-nunit – Parker May 16 '23 at 00:19
  • Due to [this](https://stackoverflow.com/questions/76258850/how-to-create-a-custom-task-only-for-unit-testing-using-dotnet-with-c) I trying have only one csproj :( – JRichardsz May 16 '23 at 01:35

0 Answers0