Skip to content

Add regression test for: Newlines in metadata are \n instead of \r\n on Windows #4083

Description

@rainersigwald

Steps to reproduce

Multi-line metadata has changed representation between 15.9.21 and 16.0.360. With this project:

Project file

<Project>
<ItemGroup>
 <I Include="I">
  <M>multiple
  lines
  in
  this
  metadatum</M>
 </I>
</ItemGroup>

<UsingTask TaskName="InlineTask" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
  <ParameterGroup>
    <Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
  </ParameterGroup>
  <Task>
    <Using Namespace="System"/>
    <Using Namespace="System.Linq"/>
    <Using Namespace="System.IO"/>
    <Using Namespace="System.Text"/>
    <Code Type="Fragment" Language="cs">
<![CDATA[
    var metadataString = this.Files[0].GetMetadata("M");
    var count = metadataString.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Length;

    this.Log.LogMessage(MessageImportance.High, string.Format("Count='{0}'", count));
]]>
    </Code>
  </Task>
</UsingTask>

<Target Name="Go">
 <InlineTask Files="@(I)" />
</Target>

</Project>

Expected behavior

s:\msbuild2>msbuild metadata_newlines.proj
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Count='5'

Actual behavior

S:\msbuild2>msbuild metadata_newlines.proj
Microsoft (R) Build Engine version 16.0.360-preview+g9781d96883 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Count='1'

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions