Skip to content

Feature Request: Add MsBuildArgument supports for MSBuild special characters #2719

@filzrev

Description

@filzrev

Currently MsBuildArgument constructor accept single string argument.
And this string value is passed to MSBuild command line parameter as is.

So when specified string contains MSBuild special characters
It needs manually escape these characters.
(e.g. When passing list values. It need to escape semicolon(;) char to %3B)

Is it able to handle these special characters inside MsBuildArgument class?
or add [MsBuildArgument constructor] that accept string params to handle multiple values?

Test Code

    internal class Program
    {
        static void Main(string[] args)
        {
            BenchmarkRunner.Run<Benchmarks>();
        }
    }

    [Config(typeof(CustomConfig))]
    public class Benchmarks
    {
        [Benchmark]
        public void Benchmark01()
        {
#if TEST1 && TEST2
            // DefineConstants symbols are defined as expected.
#else
            throw new Exception("DefineConstants value is unexpected value!");
#endif
        }

        public class CustomConfig : ManualConfig
        {
            public CustomConfig()
            {
                AddLogger(ConsoleLogger.Default);

                AddColumnProvider(DefaultConfig.Instance.GetColumnProviders().ToArray());
              
                AddJob(Job.ShortRun
                    .WithStrategy(RunStrategy.Monitoring)
                    .WithArguments(
                    [
                       // new MsBuildArgument("/p:DefineConstants=TEST1;TEST2"),     // Error: MSBUILD : error MSB1006: Property is not valid.
                       // new MsBuildArgument("/p:DefineConstants=\"TEST1;TEST2\""), // Double quote does not works.
                       new MsBuildArgument("/p:DefineConstants=TEST1%3BTEST2"),      // It works when using MSBuild special character
                    ])
                    .WithId("CustomJob"));

                WithOption(ConfigOptions.KeepBenchmarkFiles, true); // Use this settings for output to JobId folder
            }
        }
    }

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions