microsoft / PSRule

Validate infrastructure as code (IaC) and objects using PowerShell rules.
https://microsoft.github.io/PSRule/v2/
MIT License
396 stars 49 forks source link

Fix task TestDotNet on systems with .NET SDK 7.x #1404

Closed codepic closed 1 year ago

codepic commented 1 year ago

The task TestDotNet fails on systems with .NET SDK 7.x installed with the following error:

The filename, directory name, or volume label syntax is incorrect. :
'C:\Users\<user>\src\PSRule\tests\PSRule.Tests\obj\Debug\net6.0\C:\Users\<user>\src\PSRule\reports\PSRule.Tests.GeneratedMSBuildEditorConfig.editorconfig'

The reason for this issue is breaking changes in dotnet test command.

More specifically the switch -r means --runtime instead of --results-directory:

task TestDotNet {
    if ($CodeCoverage) {
        exec {
            # Test library
            dotnet test --collect:"Code Coverage" --logger trx -r (Join-Path $PWD -ChildPath reports/) tests/PSRule.Tests
        }
    }
    else {
        exec {
            # Test library
            # dotnet test --logger "console;verbosity=detailed" tests/PSRule.Tests
            dotnet test --logger trx -r (Join-Path $PWD -ChildPath reports/) tests/PSRule.Tests
        }
    }
}
github-actions[bot] commented 1 year ago

Thanks for raising your first issue, the team appreciates the time you have taken 😉

codepic commented 1 year ago

Never mind. I had the wrong branch open. For some reason when you fork into Azure DevOps, the main branch doesn't become the default.