-
Notifications
You must be signed in to change notification settings - Fork 4.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
Stop escaped compiler args from being mangled by MSBuild #76888
base: main
Are you sure you want to change the base?
Conversation
The TaskItem implementation from MSBuild treats the ItemSpec as file path and tries to normalize the path separators. When running on non-windows machines this means changing '\' to '/'. However this breaks how double quotes are escaped in the compiler args. By using our own implemetation of TaskItem we can use the compiler args as the ItemSpec without any modification. Resolves #72014
@@ -159,7 +159,7 @@ protected static ITaskItem[] GenerateCommandLineArgsTaskItems(List<string> comma | |||
var items = new ITaskItem[commandLineArgs.Count]; | |||
for (var i = 0; i < commandLineArgs.Count; i++) | |||
{ | |||
items[i] = new TaskItem(commandLineArgs[i]); | |||
items[i] = new ArgsTaskItem(commandLineArgs[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will change from us unconditionally escaping to unconditionally not escaping. Won't this regress scenarios where escaping is making builds work today? Consider for example that /keyfile:
is passed via commandLineArgs
. If that was using \
today it would be /
on unix but after this change it woudl still be \
correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof. Luckily many args such as Analyzers, References, Source all come from TaskItems of their own which apply the path correction. So I need to look at args which come from properties and may contain file paths.
The TaskItem implementation from MSBuild treats the ItemSpec as file path and tries to normalize the path separators. When running on non-windows machines this means changing '\' to '/'. However this breaks how double quotes are escaped in the compiler args. By using our own implementation of TaskItem we can use the compiler args as the ItemSpec without any modification.
Resolves #72014