-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Steps to reproduce
Project file (eg. named "SomeProject.csproj")
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Foo Include="foo.xml" />
</ItemGroup>
<PropertyGroup>
<_FileNamePrefixLength>$([MSBuild]::Add($(MsBuildProjectName.Length),1))</_FileNamePrefixLength>
</PropertyGroup>
<ItemGroup>
<Bar Include="@(Foo-> 'Output\$(MsBuildProjectName)-%(FileName)%(Extension)')">
<TargetPath>$([System.String]::new(%(FileName)).Substring($(_FileNamePrefixLength)))%(Extension)</TargetPath>
</Bar>
</ItemGroup>
<Target Name="Build">
<Message Text="%(Bar.Identity) -> %(Bar.TargetPath)" Importance="High" />
</Target>
</Project>Directory contents:
N/A
Command line
msbuild
Expected behavior
Build passes with output (this is msbuild 14):
Microsoft (R) Build Engine version 14.0.25123.0
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 6/28/2018 9:38:58 AM.
Project "<removed>\SomeProject.csproj" on node 1 (default targets).
Build:
Output\SomeProject-foo.xml -> foo.xml
Done Building Project "<removed>\SomeProject.csproj" (default targets).
Actual behavior
Build errors with evaluation error (msbuild 15):
Microsoft (R) Build Engine version 15.8.86-preview+g4ef6bb1fb2 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 6/28/2018 9:39:02 AM.
Project "<removed>\SomeProject.csproj" on node 1 (default targets).
<removed>\SomeProject.csproj(11,7): error MSB4184: The expression ""%(FileName)".Substring(12)" cannot be evaluated. star
tIndex cannot be larger than length of string. Parameter name: startIndex
Done Building Project "<removed>\SomeProject.csproj" (default targets) -- FAILED.
Build FAILED.
"<removed>\SomeProject.csproj" (default target) (1) ->
<removed>\SomeProject.csproj(11,7): error MSB4184: The expression ""%(FileName)".Substring(12)" cannot be evaluated. st
artIndex cannot be larger than length of string. Parameter name: startIndex
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.07
Environment data
msbuild /version output:
Microsoft (R) Build Engine version 15.8.86-preview+g4ef6bb1fb2 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
15.8.86.63054
OS info: Win 10