Skip to content

Failed to properly account for ' in string #6203

Open
@womalley

Description

@womalley

Issue Description

You guys haven't properly escaped/enclosed the strings you're using in the following build targets:

Microsoft.NET.Sdk.Razor.StaticWebAssets.targets

Deleting/renaming the user folder is not possible as the folder was created when the Azure Active Directory user was added to the computer.

Steps to Reproduce

  1. Login to a computer using a user account that contains an apostrophe in the name
  2. Open a .net core 3.1 project, or any other project that uses the Microsoft.NET.Sdk.Razor.StaticWebAssets.targets build target
  3. Try to build the project and/or run the project
  4. An error will be thrown similar to the error added to the "Actual Behavior" section below

This is where the error is initially thrown in the build target:
image

Expected Behavior

The project should properly reference the file and the project will build

Actual Behavior

The file can't be referenced because the file path contains an apostrophe (') within the user's folder name. This can be seen by the bolded folder name in the error below:

MSB4113 Specified condition "$([System.String]::Copy('%(Identity)').Replace('','/').StartsWith('wwwroot/'))" evaluates to "$([System.String]::Copy('C:\Users*BillO'Malley*.nuget\packages\wkhtmlwrapper.image\1.0.89\contentFiles\any\netstandard2.0\Executables\image.win.exe').Replace('','/').StartsWith('wwwroot/'))" instead of a boolean.

Analysis

Folder and file paths must allow for special characters and the Microsoft.NET.Sdk.Razor.StaticWebAssets.targets build target should escape these characters.

Versions & Configurations

Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.8.3.61104

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: LanguageIssues impacting the MSBuild programming language.bugneeds-designRequires discussion with the dev team before attempting a fix.triaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions