Skip to content

.NET 6: error MSB4259: Unexpected space at position N Did you forget to remove a space? #5863

Closed

Description

Issue Description

I'm guessing this was introduced in: #5672

Our build fails with:

error MSB4259: Unexpected space at position "47" of condition "$(RestoreTaskAssemblyFile.EndsWith('NuGet.exe', StringComparison.InvariantCultureIgnoreCase))". Did you forget to remove a space?

The property in question, I can fix by doing:

-<_IsRunningNuGetRestore Condition="$(RestoreTaskAssemblyFile.EndsWith('NuGet.exe', StringComparison.InvariantCultureIgnoreCase))">True</_IsRunningNuGetRestore>
+<_IsRunningNuGetRestore Condition="$(RestoreTaskAssemblyFile.EndsWith('NuGet.exe',StringComparison.InvariantCultureIgnoreCase))">True</_IsRunningNuGetRestore>

But then I just hit the next location:

-<AndroidSupportedHostJitAbisForConditionalChecks Condition=" !$(AndroidSupportedHostJitAbisForConditionalChecks.EndsWith (':')) "   >$(AndroidSupportedHostJitAbisForConditionalChecks):</AndroidSupportedHostJitAbisForConditionalChecks>
+<AndroidSupportedHostJitAbisForConditionalChecks Condition=" !$(AndroidSupportedHostJitAbisForConditionalChecks.EndsWith(':')) "   >$(AndroidSupportedHostJitAbisForConditionalChecks):</AndroidSupportedHostJitAbisForConditionalChecks>

I'm thinking these should be valid, as lots of our existing MSBuild targets would probably break.

Steps to Reproduce

  1. Use: https://dotnetcli.azureedge.net/dotnet/Sdk/6.0.100-alpha.1.20554.10/dotnet-sdk-6.0.100-alpha.1.20554.10-win-x64.exe
  2. dotnet build this foo.proj file:
<Project>
  <PropertyGroup>
    <Foo>ABCD</Foo>
  </PropertyGroup>
  <ItemGroup Condition="$(Foo.StartsWith ('A'))">
    <Bar Include="True" />
  </ItemGroup>
  <Target Name="Build">
    <Message Importance="High" Text="Foo: $(Foo) Bar: @(Bar)" />
  </Target>
</Project>

Expected Behavior

Build succeeds.

Actual Behavior

Build fails with:

foo.proj(5,14): error MSB4259: Unexpected space at position "16" of condition "$(Foo.StartsWith ('A'))". Did you forget to remove a space?

Analysis

Only guess is something in: #5672

Versions & Configurations

> dotnet --version
6.0.100-alpha.1.20554.10

Attach a binlog

msbuild.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions