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

7.3.0 introduced odd behaviour when passing parentheses as arguments to some other programs #18767

Closed
5 tasks done
philipp-naused opened this issue Dec 12, 2022 · 2 comments
Closed
5 tasks done

Comments

@philipp-naused
Copy link

Prerequisites

Steps to reproduce

I noticed some odd behavior when trying to pass an argument with escaped parentheses to some external programs.

Passing escaped parentheses to some programs no longer works correctly in PowerShell 7.3.0:
e.g.:
dotnet test """$(where.exe dotnet)"""
results in error:
C:\Program Files\dotnet\dotnet.exe(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

This only happens with PowerShell 7.3.0. It does not happen in 7.2.7 or 5.1.

I don't think this is a bug in dotnet.exe (7.0.100) since I have also tried this with nunit3-console (3.16.0):
When using nunit3-console the error is

System.ArgumentException : Illegal characters in path.

--ArgumentException
Illegal characters in path.
   at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at NUnit.Engine.TestPackage..ctor(String filePath)
   at NUnit.Engine.TestPackage..ctor(IList`1 testFiles)
   at NUnit.ConsoleRunner.ConsoleRunner.MakeTestPackage(ConsoleOptions options)
   at NUnit.ConsoleRunner.ConsoleRunner.Execute()
   at NUnit.ConsoleRunner.Program.Main(String[] args)

When using PowerShell 7.2.7 or 5.1, I get the correct error:
System.BadImageFormatException : Format of the executable (.exe) or library (.dll) is invalid.

I have also tried alternate means of escaping the character:
dotnet test $('"' + "$(where.exe dotnet)" + '"')
dotnet test "`"$(where.exe dotnet)`""
All with the same result.

Note: I'm only using $(where.exe dotnet) as an arbitrary example. I get the same behavior with any assembly I try to test.

Expected behavior

Dotnet.exe returns something like:

Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in C:\Program Files\dotnet\dotnet.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

Actual behavior

C:\Program Files\dotnet\dotnet.exe(1,1): error MSB4025: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.

Error details

Get-Error does not return anything in this case.

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@philipp-naused philipp-naused added the Needs-Triage The issue is new and needs to be triaged by a work group. label Dec 12, 2022
@philipp-naused
Copy link
Author

Ok, I just found #18554 and #18694

Seems that this is an undocumented breaking change in 7.3.0 that may get reverted in 7.3.1.

If I'm right about this, I suppose this issue can be closed as a duplicate of #18554.

@philipp-naused philipp-naused closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2022
@ghost ghost removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Dec 12, 2022
@philipp-naused philipp-naused closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2022
@mklement0
Copy link
Contributor

Nothing has changed in 7.3.1 so far.
For a relevant discussion, see:

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

No branches or pull requests

2 participants