Skip to content
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

nunit3-console.exe unable to find dll when AppendTargetFrameworkToOutputPath is added to project #38

Closed
ThisWholeDev opened this issue Mar 15, 2021 · 5 comments · Fixed by #46
Assignees
Labels
Milestone

Comments

@ThisWholeDev
Copy link

I just recently upgraded some of our projects to the SDK style project but have ran into an issue where adding <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> is failing because nunit3-console.exe is failing to find any of the correct dll's because it is still looking in Debug\net472 folder

I was able to reproduce the issue by creating a new project with the following csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net472</TargetFramework>
        <IsPackable>false</IsPackable>
        <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="NUnit" Version="3.12.0" />
        <PackageReference Include="NUnit.ConsoleRunner" Version="3.12.0" />
        <PackageReference Include="NUnit.Runners" Version="3.12.0" />
        <PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
    </ItemGroup>
</Project>

Command being ran:

"{packageLocation}\nunit.consolerunner\3.12.0\tools\nunit3-console.exe" TestExample.sln

The output from the previous command:

PS C:\git\test> & "{packagesLocation}\nunit.consolerunner\3.12.0\tools\nunit3-console.exe" TestExample.sln --trace=Debug
NUnit Console Runner 3.12.0 (.NET 2.0)
Copyright (c) 2021 Charlie Poole, Rob Prouse
Monday, March 15, 2021 10:48:57 AM

Runtime Environment
   OS Version: Microsoft Windows NT 6.2.9200.0
   Runtime: .NET Framework CLR v4.0.30319.42000

Test Files
    TestExample.sln


Errors, Failures and Warnings

1) Invalid : C:\RepoLocation\test\TestExample\bin\Debug\net472\TestExample.dll
File not found: C:\RepoLocation\test\TestExample\bin\Debug\net472\TestExample.dll

Test Run Summary
  Overall result: Failed
  Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
  Start time: 2021-03-15 14:48:57Z
    End time: 2021-03-15 14:48:58Z
    Duration: 0.536 seconds

Results (nunit3) saved as TestResult.xml

I have tried running the command with --trace=Debug and --inprocess as the bug report suggested and there is no difference.

The versions of all of the packages is as show above.

If I am missing something please let me know. We only call the console from our build process so I am a bit unfamiliar with the console runner.

@ThisWholeDev ThisWholeDev changed the title nunit3-console.exe unable to find dll when AppendTargetFrameworkToOutputPat is added to project nunit3-console.exe unable to find dll when AppendTargetFrameworkToOutputPath is added to project Mar 15, 2021
@CharliePoole
Copy link
Contributor

This is actually an extension issue related to #34

Both are actually instances of an (as yet unwritten) issue about the project loader extension not supporting SDK-format projects.

I'm moving this issue to the project loader repo for follow-up.

In the short term, your workaround is to stop running solution files using the console runner. If you have a relatively small fixed list of test assemblies, run them directly for now. Or create a .nunit project file, which will allow you to define your own configs. Note that while "config" in a .csproj file can't incorporate platforms a <config> element in a .nunit file can represent anything you want and use any path you want.

@CharliePoole CharliePoole transferred this issue from nunit/nunit-console Mar 15, 2021
@makersky
Copy link

makersky commented May 4, 2021

I had similar problem, adding

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <OutputPath>bin\x64\Debug\</OutputPath>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
  </PropertyGroup>

to csproj test file solved the issue.

@CharliePoole
Copy link
Contributor

@makersky Yes, that solves a specific problem... i.e. a project that defaults the OutputPath. The more general problem is that SDK-style projects can default a lot of things!

Still I think I'll add this suggestion in the docs somewhere.

@CharliePoole
Copy link
Contributor

Fixed by adding a check for the specific property but a more general approach is needed overall for the future.

@CharliePoole
Copy link
Contributor

🎉 This issue has been resolved in version 3.9.0 🎉

The release is available on:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants