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

Text log format doesn't distinguish between item metadata and new items #3966

Closed
jachin84 opened this issue Nov 29, 2018 · 11 comments
Closed

Comments

@jachin84
Copy link

I'm attempting to create an ItemGroup with some additional metadata and when the metadata spans multiple lines I get empty items created.

Steps to reproduce

Project file

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="BuildAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  
  <PropertyGroup>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>

  <!-- This Item Group defines all the Web Projects that need to be built and deployed -->
  <ItemGroup>
    <ProjectsFiles Include="Project1" />
    <ProjectsFiles Include="Project2" />
    <ProjectsFiles Include="Project3" />
  </ItemGroup>

  <Target Name="BuildAll" >
    <Message Text="Building Projects" Importance="high"/>

    <!-- Work out the correct project properties -->
    <ItemGroup>
      <_ProjectsFiles Include="@(ProjectsFiles)">
        <AdditionalProperties>
        AutoParameterizationWebConfigConnectionStrings=false;
        _PackageTempDir=Out\Dir;
        </AdditionalProperties>
      </_ProjectsFiles>
    </ItemGroup>

    <MSBuild Projects="$(MSBuildThisFileFullPath)"
             BuildInParallel="true"
             ContinueOnError="false"
             Targets="OutputMessage"
             Properties="ProjectName=%(ProjectsFiles.Identity)" />

  </Target>

  <Target Name="OutputMessage">
    <Message Text="Building Project $(ProjectName)" Importance="high"/>
  </Target>
</Project>

Expected behavior

image

Actual behavior

image

Environment data

Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

15.9.20.62856

OS info:
Windows 10 1809

@dasMulli
Copy link
Contributor

I believe this is a bug in the log viewer rather than msbuild. cc @KirillOsenkov

    <Message Importance="high" Text="@(_ProjectsFiles->'%(Identity): %(AdditionalMetadata)')" />

or similar are fine.

@jachin84
Copy link
Author

I think you might be right.

@rainersigwald
Copy link
Member

This issue was moved to KirillOsenkov/MSBuildStructuredLog#224

@KirillOsenkov
Copy link
Member

First of all, thanks for the very detailed bug report and an easy to reproduce issue.

Unfortunately this is one of the few places in MSBuild where logging doesn't have enough structure. The log message has this exact text:

Added Item(s): 
    _ProjectsFiles=
        Project1
                AdditionalProperties=
        AutoParameterizationWebConfigConnectionStrings=false;
        _PackageTempDir=Out\Dir;
        
        Project2
                AdditionalProperties=
        AutoParameterizationWebConfigConnectionStrings=false;
        _PackageTempDir=Out\Dir;
        
        Project3
                AdditionalProperties=
        AutoParameterizationWebConfigConnectionStrings=false;
        _PackageTempDir=Out\Dir;
       

The viewer is already using various heuristics to recover structure here:
https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/fc35c5ad00fae83a0683aed1f3387b6bcd2d95e7/src/StructuredLogger/Construction/ItemGroupParser.cs#L17

However by looking at the text above the indentation of 8 spaces for the multiline metadata really leaves us no way of knowing that it's the continuation of the metadata value from the previous line.

Ideally the log message would have a more structured representation of items and metadata, however I'm afraid it's not doable because of backwards compatibility.

Lets keep the issue open on the MSBuild side as well to see if we can improve logging of added items with multiline metadata. Maybe emitting text delimiters?

@KirillOsenkov
Copy link
Member

I've at least fixed the empty items in the viewer, however the metadata value is still not parented under the metadata because the indentation in the text log is wrong:
image

As a workaround put the values on a single line.

I'll keep thinking if it's possible to add more structure to the logging here.

@KirillOsenkov
Copy link
Member

OK I have an idea how to fix this.

When we print the metadata value that contains multiple lines we should split the value into individual lines and indent each line 8 spaces. This way the indentation will be correct in both the text log and the log viewer.

I may prepare a PR at some point, but probably not soon.

@KirillOsenkov KirillOsenkov self-assigned this Nov 29, 2018
@jachin84
Copy link
Author

Thanks for taking a look so quickly!

@rainersigwald rainersigwald changed the title Empty Items created when metadata spans multiple lines Text log format doesn't distinguish between item metadata and new items Jan 18, 2019
@KirillOsenkov
Copy link
Member

I need to test this scenario to make sure #6155 fixes it properly.

@KirillOsenkov
Copy link
Member

Confirmed that #6155 fixes it properly:

image

@KirillOsenkov
Copy link
Member

Compare with current behavior:

image

@KirillOsenkov
Copy link
Member

Fixed by #6155

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

No branches or pull requests

5 participants