Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item Functions are not parsed correctly in conditions #368

Closed
rainersigwald opened this issue Nov 24, 2015 · 2 comments
Closed

Item Functions are not parsed correctly in conditions #368

rainersigwald opened this issue Nov 24, 2015 · 2 comments
Labels
help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. triaged

Comments

@rainersigwald
Copy link
Member

This came up on an internal mailing list. A user was trying to emit a message if an item didn't contain a certain element, and I recommended using the Item Function AnyHaveMetadataValue. But that produces an error:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <MainEmbeddedFiles Include="foo.baml" />
    <MainEmbeddedFiles Include="UserControl1.baml" />
  </ItemGroup>

  <Target Name="b">
    <Error Text="Missing expected BAML file!!!"
           Condition="!@(MainEmbeddedFiles->AnyHaveMetadataValue('Filename', 'UserControl1'))" />
  </Target>
</Project>
d:\play>msbuild test.proj /v:q /nologo
d:\play\test.proj(9,12): error MSB4092: An unexpected token ")" was found at character position 71 in condition "!@(MainEmbeddedFiles->AnyHaveMetadataValue('Filename', 'UserControl1'))".

This can be worked around by creating a property:

  <Target Name="b">
    <PropertyGroup>
      <HasFile>@(MainEmbeddedFiles->AnyHaveMetadataValue('Filename', 'UserControl1'))</HasFile>
    </PropertyGroup>
    <Error Text="Missing expected BAML file!!! @(MainEmbeddedFiles->AnyHaveMetadataValue('Filename', 'UserControl1'))"
           Condition="!$(HasFile)" />
  </Target>

I see no reason that we should behave differently in a Condition.

@rainersigwald rainersigwald added the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label Nov 24, 2015
@nikson
Copy link
Contributor

nikson commented Jan 14, 2016

Is it still open for grab?

@rainersigwald
Copy link
Member Author

@nikson Yes, this is still up for grabs. However, it's in a part of the code that hasn't seen changes in a while, so we'd like to be cautious. If you'd like to take a look, can you post a quick summary of the changes you think you'll make before going all the way through the fix? (Of course, if it's easier to just send a PR with a proposed fix, that's fine, but I'd like to potentially save some of your time by considering an approach first.)

rozumak added a commit to rozumak/msbuild that referenced this issue Jan 25, 2016
AndyGerlicher added a commit that referenced this issue Jan 27, 2016
#368 fixed Scanner to consume correct close paren.
stinos added a commit to stinos/micropython that referenced this issue May 1, 2017
Versions prior to v14.0 have a bug in parsing item functions when used
within a condition: dotnet/msbuild#368.
Since commit [db9c2e3] this results in an error when building MicroPython
with for example VS2013.
Fix this by creating an intermediate property.
dpgeorge pushed a commit to micropython/micropython that referenced this issue May 3, 2017
Versions prior to v14.0 have a bug in parsing item functions when used
within a condition: dotnet/msbuild#368.
Since commit [db9c2e3] this results in an error when building MicroPython
with for example VS2013.
Fix this by creating an intermediate property.
toolmacher pushed a commit to toolmacher/micropython that referenced this issue May 11, 2017
Versions prior to v14.0 have a bug in parsing item functions when used
within a condition: dotnet/msbuild#368.
Since commit [db9c2e3] this results in an error when building MicroPython
with for example VS2013.
Fix this by creating an intermediate property.
radical pushed a commit to radical/msbuild that referenced this issue Apr 21, 2020
…0317.5 (dotnet#368)

- Microsoft.Dotnet.Toolset.Internal - 3.1.201-servicing.20167.5

Dependency coherency updates

- Microsoft.DotNet.Cli.Runtime - 3.1.201-servicing.20167.3 (parent: Microsoft.Dotnet.Toolset.Internal)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. triaged
Projects
None yet
Development

No branches or pull requests

3 participants