-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: why not add IsTestProject
to project property when create a test project?
#3790
Comments
The |
when I create the project in vs, it may like this https://github.com/WeihanLi/WeihanLi.Npoi/blob/b03d4f54d75ee40038cf52652dedad2f0723a32e/test/WeihanLi.Npoi.Test/WeihanLi.Npoi.Test.csproj, you can not run your tests on travis or Azure Devops unless add
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\WeihanLi.Npoi\WeihanLi.Npoi.csproj" />
</ItemGroup>
</Project> |
Is that Tests in VS or other pieces of software? I’m not sure this should be in templates if it might be a bug in other software looking for this in XML (which they probably shouldn’t do) |
it works well on my local develop environment (windows 10), but not work on Azure Devops(event Windows Agent) or travis sample build history here:
|
…207.2 (#3790) - Microsoft.NETCore.Compilers - 3.4.1-beta4-19607-02
Hi @WeihanLi . I just ran into this error too. Did you find a solution to this? Where do I have to add true in my project. I wasn't able to find this properly explained anywhere. Or is this just an issue of incompatible vs/dotnet/msbuild versions? Or can I overwrite this on the comandline? |
Hi @joergsesterhenn , I just add |
I have the same problem: 1>Done building target "ShowCallOfVSTestTaskWithParameter" in project "FunctionalTests.csproj".
When using DotNetCoreCLI@2 command 'test' with SDK 5.0.101 Adding <IsTestProject>true</IsTestProject> solved the problem |
@CarlosLanderas, does your project reference Microsoft.NET.Test.Sdk, and which version? Its Microsoft.NET.Test.Sdk.props would set the |
Yes, we are using Directory.Build.Targets with the following version: <PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.7.1" /> csproj references: <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Moq" />
<PackageReference Include="Respawn" />
<PackageReference Include="FluentAssertions" />
</ItemGroup> PD: I have another project with version 16.9.4 and I have the same problem PD2: If I move the dotnet test execution to a shell script and trigger it in Azure Devops it works. Could it be some kind of problem with the Azure Devops Dotnet CLI task? |
Please fix this issue or make it clear somewhere in docs. I spent about five hours battling this (ADO Pipelines refusing to run tests) yesterday. No fun, no fun at all |
I am observing this issue in general (i.e. when executing |
I'm also experiencing this when building my project in GitHub. This was the error:
After I added Some other notes:
Right now the workaround to add the Any ideas what might be wrong here? Let me know if you need more details. |
I ran into this problem when building the project as root and trying to run the tests as a non-root user. I believe the problem comes down to A workaround is setting To see the issue: FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
RUN dotnet new xunit --name TestProject --output . --no-restore
ARG NUGET_PACKAGES
ENV NUGET_PACKAGES=${NUGET_PACKAGES}
RUN dotnet restore TestProject.csproj
RUN dotnet build TestProject.csproj --configuration Release --output /app/build --no-restore Running the tests as root works: $ docker build -t issue-3790 --quiet .
sha256:02b63fadacaf72fd215a105dcdf366d36c58eef08f0e9618a732cede18df7d6d
$ docker run --rm issue-3790 dotnet test --no-build --output /app/build
Test run for /app/build/TestProject.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.2.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /app/build/TestProject.dll (net6.0)
$ Running the tests as a non-root user gives no output: $ docker run --rm --user 1000 -e DOTNET_CLI_HOME=/tmp issue-3790 dotnet test --no-build --output /app/build
$ But if you set $ docker build -t issue-3790 --quiet --build-arg NUGET_PACKAGES=/tmp/.nuget/packages .
sha256:655c8e20298adcf7fa8f187c4c66f2189d1c5fab7e2aa356b09c60d8f86521c2
$ docker run --rm --user 1000 -e DOTNET_CLI_HOME=/tmp issue-3790 dotnet test --no-build --output /app/build
Test run for /app/build/TestProject.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.2.0 (x64)
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /app/build/TestProject.dll (net6.0)
$ |
I've hit this problem as well, with inconsistent behavior on Azure Pipelines CI. We have two jobs which run in parallel (one with .NET Framework 4.8 UTs, another with .NET 6 UTs) and it's very strange that one of them is failing when using When examining the logs of a successful vs failed job (for the same TFM, different executions), we've noticed that the difference is the Can there be something in the execution of |
I have found the solution for this problem. This is my scenario:
If I run this, it fails: dotnet test --configuration Release --list-tests --nologo --no-build If I I with I did not have to restore again. Adding Not having the package at |
Given the last few comments I'd like to add that for my scenario, even if I run an admin shell on my Windows dev machine and whether or not I do a nuget restore before I try to build/run the tests I still get the same error due to the packages on the The workaround for me remains to add the |
I have same issue as @edumserrano - we have condition in Directory.Build.props to include some nuget packages only to test projects. This solution worked very well but something changed and now it is not working. It looks like it only works in VS but not in CLI. |
@edumserrano |
@OwnageIsMagic is correct - if you need a more convenient timing for these kinds of modifications, use a Directory.Build.targets file - there's a template for both targets and props files in the .Net 8 SDK you can use as a starter. |
@OwnageIsMagic I'm not sure what you're trying to say with your comment. That condition you linked most definitely works for my setup in that repo... |
@edumserrano |
@OwnageIsMagic I don't mean to contradict you but if you read my comment here you can see that when running a They do work once that property is added. Nothing else changes in the above setup, not even the |
@edumserrano try cleaning up your nuget cache folder ( |
@OwnageIsMagic Do note that the problem is running on the GitHub pipeline which would have a fresh Thanks for the feedback. I do think this GitHub issue is still unresolved. The |
The team I work on was recently affected by the issue where tests are skipped with However, I began looking deeper at the |
@giggio - thank you for your detailed description in your comment. It has allowed me to fix the same issue here - basically I am only uploading build artifacts between GitHub actions jobs, and not doing a build or NuGet restore. |
Closing this issue as it's fixed on test-templates side. |
As the title, why not add
<IsTestProject>true</IsTestProject>
to the test project,it seemed the ci platform like azure devops and travis will not run the test when no
<IsTestProject>true</IsTestProject>
specifiedThe text was updated successfully, but these errors were encountered: