Severity Code Description Project File Line Suppression State Error MSB4100 Expected "$([System.String]::Copy('%(Identity)').EndsWith('.resources.dll'))" to evaluate to a boolean instead of "$([System.String]::Copy('C:\Users\tarek\OneDrive\Desktop\StoreAp

م.طارق علي 5 Reputation points
2024-05-08T03:16:48.12+00:00

Severity Code Description Project File Line Suppression State

Error MSB4100 Expected "$([System.String]::Copy('%(Identity)').EndsWith('.resources.dll'))" to evaluate to a boolean instead of "$([System.String]::Copy('C:\Users\tarek\OneDrive\Desktop\StoreApi's\AllStoreApp\StoreClassLibrary\bin\Release\net8.0\StoreClassLibrary.dll').EndsWith('.resources.dll'))", in condition "!$([System.String]::Copy('%(Identity)').EndsWith('.resources.dll'))". StoreWeb C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\8.0.3\Sdk\WasmApp.targets 339

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | Blazor
Developer technologies | .NET | .NET MAUI
{count} vote

2 answers

Sort by: Most helpful
  1. Doaa Ali Hamdan AL-Jarwani 255 Reputation points
    2025-06-14T15:59:41.8733333+00:00

    Cause:

    This condition:

    !$([System.String]::Copy('%(Identity)').EndsWith('.resources.dll'))

    returns a string, not a Boolean, which MSBuild expects.

    Why:

    %(Identity) only works inside <ItemGroup> iterations — not with static paths.

    Fix It

    Option 1 – Use in ItemGroup:

    <ItemGroup>

      <MyAssemblies Include="@(ReferencePath)">

        <IsNotResource>$([System.String]::Copy('%(Identity)').EndsWith('.resources.dll'))</IsNotResource>

      </MyAssemblies>

    </ItemGroup>

    Option 2 – Use Property for Static Path:

    <PropertyGroup>

      <MyFilePath>Path\To\Your.dll</MyFilePath>

    </PropertyGroup>

    <SomeElement Condition="!$([System.String]::Copy('$(MyFilePath)').EndsWith('.resources.dll'))">

    1 person found this answer helpful.
    0 comments No comments

  2. Danny Nguyen (WICLOUD CORPORATION) 165 Reputation points Microsoft External Staff
    2025-06-19T09:58:42.8766667+00:00

    Hi @م.طارق علي.

    I have reviewed your problem and after testing, I have found that @MariMars suggestion is correct: The apostrophe (') in folder name StoreApi's did result in this error!

    To solve this issue, simply change your folder StoreApi's that contains this StoreClassLibrary Class Library to StoreApis, Store-Apis, or Store_Apis (you should probably avoid special characters as I will explain below).

    The file WasmApp.targets that rises this problem isn't exactly the problem as it is part of the system dotnet file and shouldn't be tampered with.

    Here's the cause of the problem:

    • The problem arises when the evaluated %(Identity) (which is the file path) contains an apostrophe, like in StoreApi's. When MSBuild tries to evaluate this: $([System.String]::Copy('StoreApi's\path\to\file\StoreClassLibrary.dll').EndsWith('.resources.dll')) The apostrophe within StoreApi's likely confuses MSBuild's parser. It might prematurely interpret the apostrophe as the closing single quote of the string literal 'StoreApi'. This would leave the rest of the path (s\path\to...) and the EndsWith method call as unexpected, unparseable mix to MSBuild, preventing it from correctly identifying and invoking the System.String.EndsWith method.
    • This thus results in the error MSB4100 as the parser doesn't correctly identify the entire expression as a valid .NET method call that should return a boolean. This doesn't mean the parser treat the expression as a string but just as the representation of the unevaluated mix coded.
    • This is not a WasmApp.targets Bug itself. The .targets file assumes valid, properly-formed paths will be passed to it. The issue arises because the input data (your folder path) contains a character that causes MSBuild's XML parsing engine to misinterpret the expression.

    I hope this clears up the problem, please reach out if there are any problems.
    Thanks again to @MariMars for correctly identifying the cause.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.