I am trying to set up a build definition on tfs for .NET core which includes a test step with XUnit. Everything works fine until my tests pass, and then for some reason, the build fails immediately after.
Total tests: 2. Passed: 2. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 3.3499 Seconds
Error: d:\a\_tool\dncs\2.0.0\x64\dotnet.exe failed with return code: 1
Dotnet command failed with non-zero exit code on the following projects :
That's it, no other detail. I am confused where to go from here, the test step is currently the last one in the build definition.
EDIT
This is the verbose output obtained by setting debug = true
2017-10-19T09:50:00.4882598Z ##[debug]rc:1
2017-10-19T09:50:00.4902607Z ##[debug]success:false
2017-10-19T09:50:00.5002614Z ##[error]Error:
d:\a\_tool\dncs\2.0.0\x64\dotnet.exe failed with return code: 1
2017-10-19T09:50:00.5002614Z ##[debug]Processed: ##vso[task.issue
type=error;]Error: d:\a\_tool\dncs\2.0.0\x64\dotnet.exe failed with return
code: 1
2017-10-19T09:50:00.5022599Z ##[debug]task result: Failed
2017-10-19T09:50:00.5032599Z ##[error]Dotnet command failed with non-zero
exit code on the following projects :
2017-10-19T09:50:00.5032599Z ##[debug]Processed: ##vso[task.issue
type=error;]Dotnet command failed with non-zero exit code on the following
projects :
2017-10-19T09:50:00.5042604Z ##[debug]Processed: ##vso[task.complete
result=Failed;]Dotnet command failed with non-zero exit code on the
following projects :
Try following bellow items:
Open the project file (eg *.csproj) comment out below snippet:
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="X.X.XXX" />
Create a new build definition with ASP.NET Core (.NET Framework)
template used.
Also reference this thread : VSTS build: Packages failed to restore - Unable to resolve 'NETStandard.Library (>= 1.6.1)' for '.NETStandard,Version=v2.0'
So I fixed the issue by modifying the csproj file in the test project and adding a cli tool reference like so
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="Moq" Version="4.7.142" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.18" />
<PackageReference Include="MSTest.TestFramework" Version="1.1.18" />
<PackageReference Include="xunit" Version="2.3.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" /> <-- This bit here!!!
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
</ItemGroup>
In the build process on TFS, I removed the Dotnet test step and added in its place a command line step and configured it as I did below. Everything works now and the build is successful.
Related
I've configured a DevOps pipeline to execute my SpecFlow Selenium tests. Everything appears to work fine, except that all my test scenarios are skipped on the DevOps agent.
When I run the tests locally, using VS2019 test explorer, they run without issues.
I've tried enabling system diagnostics to see why they are being skipped but couldn't see anything that could be the cause.
Here's the YAML for the VSTest task:
steps:
- task: VSTest#2
displayName: 'VsTest - RetroSpectro.Tests.UI.Specflow.dll'
inputs:
testAssemblyVer2: |
**\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
!**\*TestAdapter.dll
!**\obj\**
!**\bin\**\ref\**
uiTests: true
runSettingsFile: RetroSpectro.Tests.UI.Specflow/Serial.runsettings
pathtoCustomTestAdapters: packages
runTestsInIsolation: true
testRunTitle: 'SpecFlow Tests'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
failOnMinTestsNotRun: true
rerunFailedTests: false
... and the output from task execution:
2021-06-25T09:02:15.0841271Z ##[section]Starting: VsTest - RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:15.1180446Z ==============================================================================
2021-06-25T09:02:15.1180820Z Task : Visual Studio Test
2021-06-25T09:02:15.1181621Z Description : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
2021-06-25T09:02:15.1182585Z Version : 2.170.1
2021-06-25T09:02:15.1183892Z Author : Microsoft Corporation
2021-06-25T09:02:15.1184298Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/test/vstest
2021-06-25T09:02:15.1184712Z ==============================================================================
2021-06-25T09:02:16.6157598Z SystemVssConnection exists true
2021-06-25T09:02:16.7413804Z SystemVssConnection exists true
2021-06-25T09:02:16.9135626Z Running tests using vstest.console.exe runner.
2021-06-25T09:02:16.9136452Z ======================================================
2021-06-25T09:02:16.9138232Z Test selector : Test assemblies
2021-06-25T09:02:16.9139517Z Test filter criteria : null
2021-06-25T09:02:16.9140779Z Search folder : D:\a\1\s
2021-06-25T09:02:16.9937367Z Action when minimum tests threshold not met : fail
2021-06-25T09:02:16.9938318Z Minimum tests expected to be run: 1
2021-06-25T09:02:16.9939834Z VisualStudio version selected for test execution : latest
2021-06-25T09:02:16.9943536Z Attempting to find vstest.console from a visual studio installation with version [16.0,17.0).
2021-06-25T09:02:16.9973962Z Run settings file : D:\a\1\s\RetroSpectro.Tests.UI.Specflow\Serial.runsettings
2021-06-25T09:02:16.9981237Z Run in parallel : false
2021-06-25T09:02:16.9984189Z Run in isolation : true
2021-06-25T09:02:16.9986763Z Path to custom adapters : D:\a\1\s\packages
2021-06-25T09:02:16.9991903Z Other console options : null
2021-06-25T09:02:16.9994735Z Code coverage enabled : false
2021-06-25T09:02:17.0001246Z Diagnostics enabled : false
2021-06-25T09:02:17.0008374Z SystemVssConnection exists true
2021-06-25T09:02:17.0368729Z Run the tests locally using vstest.console.exe
2021-06-25T09:02:17.0369728Z ========================================================
2021-06-25T09:02:17.0464264Z Source filter: **\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll,!**\*TestAdapter.dll,!**\obj\**,!**\bin\**\ref\**
2021-06-25T09:02:22.7152869Z SystemVssConnection exists true
2021-06-25T09:02:22.7157229Z [command]D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe --inputFile D:\a\_temp\input_0dad9d50-d594-11eb-bac6-a972b6c3989e.json
2021-06-25T09:02:22.7158487Z ======================================================
2021-06-25T09:02:22.8592004Z ##########################################################################
2021-06-25T09:02:22.8592761Z DtaExecutionHost version 18.170.30112.1.
2021-06-25T09:02:23.7498265Z Starting TestExecution Model...
2021-06-25T09:02:26.9047814Z Result Attachments will be stored in LogStore
2021-06-25T09:02:26.9297128Z Run Attachments will be stored in LogStore
2021-06-25T09:02:26.9433340Z Result Attachments will be stored in LogStore
2021-06-25T09:02:27.1235011Z Result Attachments will be stored in LogStore
2021-06-25T09:02:27.1235834Z Run Attachments will be stored in LogStore
2021-06-25T09:02:27.1470266Z Provided settings file:
2021-06-25T09:02:27.1485829Z <?xml version="1.0" encoding="utf-8"?>
2021-06-25T09:02:27.1486598Z <RunSettings>
2021-06-25T09:02:27.1487139Z <SpecRun>
2021-06-25T09:02:27.1488252Z <Profile>Serial.srprofile</Profile>
2021-06-25T09:02:27.1488944Z <GenerateFeatureTrait>true</GenerateFeatureTrait>
2021-06-25T09:02:27.1490018Z </SpecRun>
2021-06-25T09:02:27.1490506Z </RunSettings>
2021-06-25T09:02:27.1785620Z Updated Run Settings:
2021-06-25T09:02:27.1788682Z <RunSettings>
2021-06-25T09:02:27.1788992Z <SpecRun>
2021-06-25T09:02:27.1789483Z <Profile>Serial.srprofile</Profile>
2021-06-25T09:02:27.1789897Z <GenerateFeatureTrait>true</GenerateFeatureTrait>
2021-06-25T09:02:27.1790256Z </SpecRun>
2021-06-25T09:02:27.1790560Z <RunConfiguration>
2021-06-25T09:02:27.1790961Z <BatchSize>1000</BatchSize>
2021-06-25T09:02:27.1791385Z <ResultsDirectory>D:\a\_temp\TestResults</ResultsDirectory>
2021-06-25T09:02:27.1791975Z </RunConfiguration>
2021-06-25T09:02:27.1792294Z </RunSettings>
2021-06-25T09:02:27.1979593Z **************** Starting test execution *********************
2021-06-25T09:02:27.2197434Z [command]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "#D:\a\_temp\y3jxhopis4l.tmp"
2021-06-25T09:02:27.4233968Z Microsoft (R) Test Execution Command Line Tool Version 16.10.0
2021-06-25T09:02:27.4235225Z Copyright (c) Microsoft Corporation. All rights reserved.
2021-06-25T09:02:27.4413296Z vstest.console.exe "D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll"
2021-06-25T09:02:27.4414588Z /Settings:"D:\a\_temp\kpbetfmovlq.tmp.runsettings"
2021-06-25T09:02:27.4415655Z /InIsolation
2021-06-25T09:02:27.4416622Z /Logger:"trx"
2021-06-25T09:02:27.4417670Z /TestAdapterPath:"D:\a\1\s\packages"
2021-06-25T09:02:29.1247592Z Starting test execution, please wait...
2021-06-25T09:02:30.0040388Z A total of 1 test files matched the specified pattern.
2021-06-25T09:02:33.0429462Z SpecFlow+Runner execution started
2021-06-25T09:02:33.0431615Z SpecFlow+Runner 3.9.7 in Framework net50 in x64 mode execution started
2021-06-25T09:02:33.0433131Z TestAdapter Location: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\TechTalk.SpecRun.VisualStudio.TestAdapter.dll
2021-06-25T09:02:33.0433910Z Current UserName: 'VssAdministrator', MachineName: 'WIN-RNFTU0DQEPC'
2021-06-25T09:02:33.3384985Z SpecRun: running tests in D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.3386699Z Output folder configured to "D:\a\_temp\TestResults" (default)
2021-06-25T09:02:33.3387477Z Profile: RetroSpectro.Tests.UI.Specflow
2021-06-25T09:02:33.4638846Z Log file path: D:\a\_temp\TestResults\RetroSpectro.Tests.UI.Specflow_RetroSpectro.Tests.UI.Specflow_2021-06-25T090233.log
2021-06-25T09:02:33.4749622Z Checking activation
2021-06-25T09:02:33.4854960Z Activation check completed
2021-06-25T09:02:33.4878329Z Starting test run
2021-06-25T09:02:33.7105584Z Discovering target: Chrome
2021-06-25T09:02:33.7106665Z Discovering tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.8841939Z Discovered tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.8843042Z Discovering target: Edge
2021-06-25T09:02:33.8843914Z Discovering tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.9067409Z Discovered tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.9068593Z Discovering target: Firefox
2021-06-25T09:02:33.9069400Z Discovering tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.9193883Z Discovered tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.9195007Z Discovering target: IE
2021-06-25T09:02:33.9196501Z Discovering tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.9272484Z Discovered tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.9277522Z Discovering target: Safari
2021-06-25T09:02:33.9278613Z Discovering tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:33.9352988Z Discovered tests from assembly: D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\RetroSpectro.Tests.UI.Specflow.dll
2021-06-25T09:02:56.8250888Z Scenario: Follow button is not available in header section on Add Item page in AddEditItemFeature (target: Chrome) -> Skipped on thread #-1
...
<!-- other chrome tests also skipped on thread #-1 -->
...
2021-06-25T09:02:56.8376857Z Scenario: Group description is available in header section on Edit Item page in AddEditItemFeature (target: Edge) -> Skipped on thread #-1
...
<!-- other edge tests also skipped on thread #-1 -->
...
2021-06-25T09:02:56.8518611Z Scenario: Group status is available in header section on Add Item page in AddEditItemFeature (target: Firefox) -> Skipped on thread #-1
...
<!-- other firefox tests also skipped on thread #-1 -->
...
2021-06-25T09:02:56.8587604Z Scenario: Group description is available in header section on Add Item page in AddEditItemFeature (target: IE) -> Skipped on thread #-1
...
<!-- other IE tests also skipped on thread #-1 -->
...
2021-06-25T09:02:56.8648632Z Scenario: Title label is displayed on Add Item page in AddEditItemFeature (target: Safari) -> Skipped on thread #-1
...
<!-- other Safari tests also skipped on thread #-1 -->
...
2021-06-25T09:02:56.8764035Z test run finished
2021-06-25T09:02:56.8765441Z publishing test results
2021-06-25T09:02:56.8766131Z Not publishing results.
2021-06-25T09:02:56.8766729Z test results published
2021-06-25T09:02:56.8767274Z generating reports
2021-06-25T09:02:56.9558142Z Starting external report generation process
2021-06-25T09:02:56.9590180Z Starting external program: "D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\SpecFlowPlusRunner\net461\SpecFlow.Plus.Runner.Reporting.exe" "C:\Users\VssAdministrator\AppData\Local\Temp\ca95d93f-da8f-41ce-9966-62cb15b332e9" in
2021-06-25T09:02:58.4457850Z Skipped Follow button is not available in header section on Add Item page [1 ms]
...
<!-- all tests were skipped in [< 1 ms] --!>
...
2021-06-25T09:03:00.2990896Z 'D:\a\1\s\RetroSpectro.Tests.UI.Specflow\bin\any cpu\release\net5.0\SpecFlowPlusRunner\net461\SpecFlow.Plus.Runner.Reporting.exe "C:\Users\VssAdministrator\AppData\Local\Temp\ca95d93f-da8f-41ce-9966-62cb15b332e9"' took 3337.3233ms
2021-06-25T09:03:00.2992974Z RAA6AFwAYQBcAF8AdABlAG0AcABcAFQAZQBzAHQAUgBlAHMAdQBsAHQAcwBcAFIAZQB0AHIAbwBTAHAAZQBjAHQAcgBvAC4AVABlAHMAdABzAC4AVQBJAC4AUwBwAGUAYwBmAGwAbwB3AF8AUgBlAHQAcgBvAFMAcABlAGMAdAByAG8ALgBUAGUAcwB0AHMALgBVAEkALgBTAHAAZQBjAGYAbABvAHcAXwAyADAAMgAxAC0AMAA2AC0AMgA1AFQAMAA5ADAAMgAzADMALgBoAHQAbQBsAA==
2021-06-25T09:03:00.2994487Z Successfully generated reports.
2021-06-25T09:03:00.3024068Z Successfully generated reports
2021-06-25T09:03:00.3157341Z Result: test framework error: At least one test thread aborted.
2021-06-25T09:03:00.3159973Z Total: 185
2021-06-25T09:03:00.3160575Z Succeeded: 0
2021-06-25T09:03:00.3161111Z Ignored: 0
2021-06-25T09:03:00.3161627Z Pending: 0
2021-06-25T09:03:00.3163981Z Skipped: 185
2021-06-25T09:03:00.3164566Z Failed: 0
2021-06-25T09:03:00.3165688Z Execution Time: 00:00:22.9059275
2021-06-25T09:03:00.3166798Z Report file: file:///D:/a/_temp/TestResults/RetroSpectro.Tests.UI.Specflow_RetroSpectro.Tests.UI.Specflow_2021-06-25T090233.html
2021-06-25T09:03:00.3168312Z Adding attachments to VSTest
2021-06-25T09:03:00.3169047Z adding Test Execution Report 'D:\a\_temp\TestResults\RetroSpectro.Tests.UI.Specflow_RetroSpectro.Tests.UI.Specflow_2021-06-25T090233.html'
2021-06-25T09:03:00.3283768Z Log file: file:///D:/a/_temp/TestResults/RetroSpectro.Tests.UI.Specflow_RetroSpectro.Tests.UI.Specflow_2021-06-25T090233.log
2021-06-25T09:03:00.3294371Z SpecFlow+Runner execution finished
2021-06-25T09:03:00.6411255Z Results File: D:\a\_temp\TestResults\VssAdministrator_WIN-RNFTU0DQEPC_2021-06-25_09_02_58.trx
2021-06-25T09:03:00.6488918Z Attachments:
2021-06-25T09:03:00.6490475Z C:\Users\VssAdministrator\AppData\Local\Temp\0erzmwe3.ry2\RetroSpectro.Tests.UI.Specflow_RetroSpectro.Tests.UI.Specflow_2021-06-25T090233.log
2021-06-25T09:03:00.6494999Z C:\Users\VssAdministrator\AppData\Local\Temp\0erzmwe3.ry2\RetroSpectro.Tests.UI.Specflow_RetroSpectro.Tests.UI.Specflow_2021-06-25T090233.html
2021-06-25T09:03:00.6813251Z Test Run Successful.
2021-06-25T09:03:00.6814110Z Total tests: 185
2021-06-25T09:03:00.6814725Z Skipped: 185
2021-06-25T09:03:00.6826934Z Total time: 30.4837 Seconds
2021-06-25T09:03:00.7194885Z Vstest.console.exe exited with code 0.
2021-06-25T09:03:00.7196364Z **************** Completed test execution *********************
2021-06-25T09:03:00.7398059Z Test results files: D:\a\_temp\TestResults\VssAdministrator_WIN-RNFTU0DQEPC_2021-06-25_09_02_58.trx
2021-06-25T09:03:01.3258001Z Created test run: 1014788
2021-06-25T09:03:01.3261282Z Publishing test results: 185
2021-06-25T09:03:01.6120517Z Publishing test results to test run '1014788'.
2021-06-25T09:03:01.6165436Z TestResults To Publish 185, Test run id:1014788
2021-06-25T09:03:01.6272324Z Test results publishing 185, remaining: 0. Test run id: 1014788
2021-06-25T09:03:02.2543932Z Published test results: 185
2021-06-25T09:03:02.2556259Z Publishing Attachments: 3
2021-06-25T09:03:03.5514586Z ##[error]The specified minimum number of tests 1 were not executed in the test run.
2021-06-25T09:03:04.2147578Z Execution Result Code 1 is non zero, checking for failed results
2021-06-25T09:03:04.3270302Z Completed TestExecution Model...
2021-06-25T09:03:04.3691332Z ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
2021-06-25T09:03:04.3697400Z ##[error]Error: The process 'D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.170.1\Modules\DTAExecutionHost.exe' failed with exit code 1
2021-06-25T09:03:04.3703872Z ##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
2021-06-25T09:03:04.3933532Z ##[section]Finishing: VsTest - RetroSpectro.Tests.UI.Specflow.dll
It looks like the test thread is being aborted but I have no idea why.
The .runsettings is relatively simple:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<SpecRun>
<Profile>Serial.srprofile</Profile>
<GenerateFeatureTrait>true</GenerateFeatureTrait>
</SpecRun>
</RunSettings>
The specflow profile is:
<?xml version="1.0" encoding="utf-8"?>
<TestProfile xmlns="http://www.specflow.org/schemas/plus/TestProfile/1.5">
<Settings projectName="RetroSpectro.Tests.UI.Specflow" />
<Execution retryFor="Failing" stopAfterFailures="0" testThreadCount="1" testSchedulingMode="Random" retryCount="2" />
<Environment framework="Net5.0" platform="x86" testThreadIsolation="AppDomain" apartmentState="STA"/>
<TestAssemblyPaths>
<TestAssemblyPath>RetroSpectro.Tests.UI.Specflow.dll</TestAssemblyPath>
</TestAssemblyPaths>
<VSTest testRetryResults="Unified" passRateAbsolute="1"/>
<Targets>
<Target name="Chrome">
<Filter>!#Parallel</Filter>
<DeploymentTransformationSteps>
<EnvironmentVariable variable="RUNNER_TARGET" value="chrome" />
</DeploymentTransformationSteps>
</Target>
<Target name="Edge">
<Filter>!#Parallel</Filter>
<DeploymentTransformationSteps>
<EnvironmentVariable variable="RUNNER_TARGET" value="edge" />
</DeploymentTransformationSteps>
</Target>
<Target name="Firefox">
<Filter>!#Parallel</Filter>
<DeploymentTransformationSteps>
<EnvironmentVariable variable="RUNNER_TARGET" value="firefox" />
</DeploymentTransformationSteps>
</Target>
<Target name="IE">
<Filter>!#Parallel</Filter>
<DeploymentTransformationSteps>
<EnvironmentVariable variable="RUNNER_TARGET" value="ie" />
</DeploymentTransformationSteps>
</Target>
<Target name="Safari">
<Filter>!#Parallel</Filter>
<DeploymentTransformationSteps>
<EnvironmentVariable variable="RUNNER_TARGET" value="safari" />
</DeploymentTransformationSteps>
</Target>
</Targets>
</TestProfile>
Any ideas why the tests are being skipped or what I can try to find out?
Edit:
I noticed that in a previous (working) run, VSTest was running scenarios in thread #-0. After a crash it started logging the "skipped in thread #-1" messages.
I am trying to build on TFS an API which contains several projects in dotnet.core3.1
When I run the dotnet build Api.sln command on TFS here is the result
[error] Dotnet command failed with non-zero exit code on the following projects: D: \ TFS \ Agent01 \ _work \ 18 \ s \ PMTApi.sln
Context:
TFS 2017
Dotnet Core 3.1 projects
Source code management on TFS git
Agents unable to connect to the outside (internet)
The dependency imports are done from a private server thanks to the NuGet.Config file set up to redirect the dependency imports not on the https://api.nuget.org/v3/index.json server but well on that of our private company.
Explanation:
On the TFS git source manager, the PMTApi.sln project contains 7 .csproj files
But in the PMTApi.sln file there are only 4 .csproj which are included
Local result:
Is good dotnet build completes the 5 successful projects.
Result on TFS:
Not good.
[error] Dotnet command failed with non-zero exit code on the following projects: D: \ TFS \ Agent01 \ _work \ 18 \ s \ PMTApi.sln
Observation:
I have the impression that TFS is based on all the .csproj files from the TFS git source manager and not from PMTApi.sln
Conclusion the projects which are not referenced in PMTApi.sln still try to restore the dependencies which causes the top error.
Test:
I tried to exclude these 3 .csproj projects in my NuGet.Config file like this, but it doesn't work
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="XXX NuGet Packages" value="http://privateServer/nuget" />
</packageSources>
<ItemGroup>
<ProjectReference Exclude="..\folderName1\projectName1.csproj" />
<ProjectReference Exclude="..\folderName2\projectName2.csproj" />
<ProjectReference Exclude="..\folderName3\projectName3.csproj" />
</ItemGroup>
</configuration>
Do you have any ideas for a successful dotnet build task?
The construction:
TFS Return:
Local configuration:
1- here you have to right click on the solution
2- manage package Nuget for solution
3- add the url of your private server
4- and uncheck the server of api.NuGet.org
for my case I also uncheck the visual studio packages
You should specify the csproj file(s) to use in the Project(s) argument, not sln file. Check the description of this argument:
The path to the csproj file(s) to use. You can use wildcards (e.g.
**/*.csproj for all .csproj files in all subfolders). This field follows glob pattern, and is run against root of the repository at all
times irrespective of Working Directory.
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops
I have this .NET Core 1.1 solution including an ASP.NET Core project and an NUnit test project. Each of projects has the necessary properties (I can show more if necessary).
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
</PropertyGroup>
I can restore, build, and run the test suite locally (Windows 10) without any problems.
$ dotnet restore
Restoring packages for...
Restore completed in...
Generating MSBuild file...
$ dotnet build
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Example -> ...
Test -> ...
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed ...
$ cd test/
$ dotnet test
Build started, please wait...
Build completed.
Test run for ...
Microsoft (R) Test Execution Command Line Tool Version 15.3.0-preview-20170628-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
NUnit Adapter 3.8.0.0: Test execution started
Running all tests in ...
NUnit3TestExecutor converted 11 of 11 NUnit test cases
Total tests: 11. Passed: 11. Failed: 0. Skipped: 0.
Test Run Succeeded.
Test execution time: ...
The test suite uses NUnit 3 and I'm on all the latest stable versions. Here are the interesting package refs.
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
<PackageReference Include="FluentAssertions" Version="4.19.3" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.3" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
However, when I run the tests from a .NET Core SDK Docker image/container, they fail dramatically!
The active test run was aborted. Reason: Unable to communicate with test host process.
Here's the simple Dockerfile
FROM microsoft/dotnet:1.1-sdk
WORKDIR /app
COPY . .
The restore and build work find, but the test aborts!
$ docker image build --tag example:latest .
...
$ docker container run --rm -it example:latest
root#abcdef12345:/app# dotnet restore
...
root#abcdef12345:/app# dotnet build
...
root#abcdef12345:/app# cd test/
root#abcdef12345:/app# dotnet test
...
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
NUnit Adapter 3.8.0.0: Test execution started
Running all tests in ...
NUnit3TestExecutor converted 11 of 11 NUnit test cases
The active test run was aborted. Reason: Unable to communicate with test host process.
Searches for this error message get me nowhere. I'm not sure how to debug a test run abort. Higher levels of verbosity do not print anything useful. Let me know what I can try to get more information, eliminate possibilities, and provide more useful info!
Update. With Matt Ward's help I traced this to a bad config file. The following ~/.config/NuGet/NuGet.Config works for me
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" protocolVersion="2" />
</packageSources>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
I can do the following without any problems:
/opt/mono/mono-5.2.0.196-tarball/bin/mono ~/nuget.exe install -version 2.6.4 nunit
However, when I try to compile fsharp under the same installation of Mono, I get the following error. This is in the fsharp4 branch. What might I be doing wrong, please? Many thanks.
Project "/dir/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj"
(default target(s)): Target CallFsSrGen: Created directory
"obj/proto/./" Tool
/dir/src/fsharp/FSharp.Build-proto/../../../lib/bootstrap/4.0/fssrgen.exe
execution started with arguments:
/dir/src/fsharp/FSharp.Build/FSBuild.txt obj/proto/./FSBuild.fs
FSBuild.resx Target BeforeBuild: Executing: mono
--runtime=v4.0.30319 /dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore
packages.config -PackagesDirectory packages Unable to find version
'2.6.4' of package 'NUnit'. Unable to find version '2.6.4' of
package 'NUnit.Runners'. /dir/src/FSharpSource.targets: error :
Command 'mono --runtime=v4.0.30319
/dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore
packages.config -PackagesDirectory packages' exited with code: 1.
Task "Exec" execution -- FAILED Done building target "BeforeBuild"
in project
Check what version of NuGet you are using and what NuGet package sources are enabled. Either there no NuGet package sources enabled or you are using a NuGet v2 .exe with a NuGet v3 package source.
If there is no NuGet.Config file that is provided with the FSharp build source code you are using then check the package sources listed in the file ~/.config/NuGet/NuGet.config. I suspect that it only has the v3 package source https://api.nuget.org/v3/index.json which cannot be used with a NuGet.exe (v2). So you would either need to update the nuget.exe to a later version or add the NuGet v2 package source into your NuGet.Config file: https://www.nuget.org/api/v2/
I'm hoping someone can help diagnose whats going wrong with my build. I'm using Visual Studio 2012, NuGet 2.7, & TFS Service (git). I've been unable to get around the following error:
"C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj (361): This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567."
I've enabled the package restore feature (but it think i've heard with nuget 2.7 it doesn't matter). Anyways i found a helpful blog about this problem at :
Blog Article
Here is my current build script:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutDir>$(MSBuildThisFileDirectory)bin</OutDir>
<Configuration>Release</Configuration>
<ProjectProperties>
OutDir=$(OutDir);
Configuration=$(Configuration);
</ProjectProperties>
</PropertyGroup>
<ItemGroup>
<Solution Include="$(MSBuildThisFileDirectory)src\*.sln" />
</ItemGroup>
<Target Name="RestorePackages">
<Exec Command=""$(MSBuildThisFileDirectory)src\.nuget\NuGet.exe" restore "%(Solution.Identity)"" />
</Target>
<Target Name="Clean">
<MSBuild Targets="Clean"
Projects="#(Solution)"
Properties="$(ProjectProperties)" />
</Target>
<Target Name="Build" DependsOnTargets="RestorePackages">
<MSBuild Targets="Build"
Projects="#(Solution)"
Properties="$(ProjectProperties)" />
</Target>
<Target Name="Rebuild" DependsOnTargets="RestorePackages">
<MSBuild Targets="Rebuild"
Projects="#(Solution)"
Properties="$(ProjectProperties)" />
</Target>
</Project>
and here is my build log:
Build started 9/27/2013 1:01:14 AM.
Project "C:\a\src\build.proj" on node 1 (default targets).
RestorePackages:
"C:\a\src\src\.nuget\NuGet.exe" restore "C:\a\src\src\RecipeDb.sln"
Project "C:\a\src\build.proj" (1) is building "C:\a\src\src\RecipeDb.sln" (2) on node 1 (Build target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (3) on node 1 (default targets).
C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj(361,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567.
Done Building Project "C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default targets) -- FAILED.
Project "C:\a\src\src\RecipeDb.sln" (2) is building "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (5) on node 1 (default targets).
C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567.
Done Building Project "C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default targets) -- FAILED.
Done Building Project "C:\a\src\src\RecipeDb.sln" (Build target(s)) -- FAILED.
Done Building Project "C:\a\src\build.proj" (default targets) -- FAILED.
Build FAILED.
"C:\a\src\build.proj" (default target) (1) ->
"C:\a\src\src\RecipeDb.sln" (Build target) (2) ->
"C:\a\src\src\RecipeDb.Mvc\RecipeDb.Mvc.csproj" (default target) (3) ->
(EnsureBclBuildImported target) ->
C:\a\src\src\RecipeDb.M
vc\RecipeDb.Mvc.csproj(361,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567.
"C:\a\src\build.proj" (default target) (1) ->
"C:\a\src\src\RecipeDb.sln" (Build target) (2) ->
"C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj" (default target) (5) ->
C:\a\src\src\RecipeDb.Mvc.Tests\RecipeDb.Mvc.Tests.csproj(144,5): error : This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567.
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:09.21
So i copied his build log and just changed the path where nuget.exe is. Nuget.exe command seems to be running but apparently its not downloading the packages. Of course building locally works fine (even if i delete the packages directory.
As I can see in the link in the error message line you posted:
There is an improvement in Nuget 2.7 as below:
The Improvement
We’ve updated Microsoft.Bcl.Build to use a different approach. The
new version will use a conditional import similar to what NuGet’s
automatic import feature does. This will always allow the project to
load in Visual Studio.
However, Microsoft.Bcl.Build also adds a target to your project
that will run after the build is finished. This target checks whether
the current build restored packages and if so fail the build with an
actionable error message:
The build restored NuGet packages. Build the project again to include
these packages in the build. For more information, see
http://go.microsoft.com/fwlink/?LinkID=317568.
Building a second time will fix this error. Please note that this
error will only appear if packages were missing so it’s not like you
always have to build twice.
However, below that it says that it will not address build server/continuous integration (CI) scenarios and it needs a solution as specified in the following excerpt from the article:
This solution doesn’t address build server / continuous integration
(CI) scenarios. In order to successfully use package restore on the
build server, you have two options:
Check-in the .targets file.
Explicitly run NuGet package restore prior to building your project/solution.
Hope the issue you are facing is also because of this only.
For me the reference to Microsoft.Bcl.Build and the BeforeTargets="BeforeBuild" was causing problems. This got added when Microsoft.Bcl.Build was added as a dependency to an Azure Nuget package.
Try checking your project file and removing it.
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>