nuke icon indicating copy to clipboard operation
nuke copied to clipboard

Rooted AbsolutePath parameter loaded from profile fails

Open tunger opened this issue 3 years ago • 0 comments

Usage Information

NUKE 6.0.1 / SDK 6.0.302 / Windows 11

Description

When providing a rooted AbsolutePath parameter from a profile, it fails with:

[ERR] Unhandled exception: Second path must not be rooted (Parameter 'HasPathRoot(right)')
System.ArgumentException: Second path must not be rooted (Parameter 'HasPathRoot(right)')
   at Nuke.Common.Assert.False(Boolean condition, String message, String argumentExpression)
   at Nuke.Common.IO.PathConstruction.Combine(String left, String right, Nullable`1 separator)
   at Nuke.Common.IO.AbsolutePath.op_Division(AbsolutePath left, String right)
   at Nuke.Common.Execution.ArgumentsFromParametersFileAttribute.<OnBuildCreated>g__ConvertValue|3_2(Type scalarType, String value)
   at Nuke.Common.Execution.ArgumentsFromParametersFileAttribute.<>c__DisplayClass3_1.<OnBuildCreated>b__8(String x)
   at System.Linq.Utilities.<>c__DisplayClass2_0`3.<CombineSelectors>b__0(TSource x)
   at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Collections.Generic.EnumerableHelpers.IterativeCopy[T](IEnumerable`1 source, T[] array, Int32 arrayIndex, Int32 count)
   at System.Collections.Generic.EnumerableHelpers.Copy[T](IEnumerable`1 source, T[] array, Int32 arrayIndex, Int32 count)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Nuke.Common.Execution.ArgumentsFromParametersFileAttribute.OnBuildCreated(NukeBuild build, IReadOnlyCollection`1 executableTargets)
   at Nuke.Common.Utilities.Collections.EnumerableExtensions.ForEach[T](IEnumerable`1 enumerable, Action`1 action)
   at Nuke.Common.NukeBuild.ExecuteExtension[TExtension](Expression`1 action)
   at Nuke.Common.Execution.BuildManager.Execute[T](Expression`1[] defaultTargetExpressions)

Probably because of this: https://github.com/nuke-build/nuke/blob/46fbb2f9aa1a548184aad66c28abef9846a5db09/source/Nuke.Common/Execution/ArgumentsFromParametersFileAttribute.cs#L54-L59

Reproduction Steps

Add a parameter to Build.cs

[Parameter] public AbsolutePath FilePath;

Provide the parameter in profile .nuke/parameters.json

{
  "$schema": "./build.schema.json",
  "FilePath": "C:\\my\\rooted\\path.json",
}

Expected Behavior

The path from the profile file should be available in the AbsolutePath property.

Actual Behavior

The build fails.

Regression?

No response

Known Workarounds

No response

tunger avatar Aug 02 '22 11:08 tunger