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

Property definition that impacts generated AssemblyInfo doesn't support CData #1294

Closed
NTaylorMullen opened this issue Nov 1, 2016 · 4 comments
Assignees
Labels

Comments

@NTaylorMullen
Copy link

From @NTaylorMullen on November 1, 2016 18:30

Adding a <Description> to my csproj that looks like:

<Description><![CDATA[Line 1
Line 2
Line 3]]></Description>

Results in the following error when trying to build:

MSBUILD : error MSB4025: The project file could not be loaded. Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 7, position 44.

Copied from original issue: dotnet/sdk#347

@rainersigwald
Copy link
Member

This works in MSBuild 14, but fails in MSBuild 15.

@rainersigwald rainersigwald changed the title CSProj Description doesn't support CData Property definition doesn't support CData Nov 1, 2016
@Sarabeth-Jaffe-Microsoft Sarabeth-Jaffe-Microsoft added this to the Visual Studio 15 RTM milestone Nov 1, 2016
@cdmihai
Copy link
Contributor

cdmihai commented Nov 15, 2016

@NTaylorMullen I tried both .netcore and full framework msbuild and they both seem to work. Can you please paste in a full repro project that fails for you, as well as the output from msbuild /version and whether it's the .net core or the full version?

Here's the project that I tested on:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <Description><![CDATA[
    <Target Name="Build">
        <ItemGroup>
           <foo Remove=""/>
        </ItemGroup>
        <Message Text="-@(foo)-"/>
    </Target>]]></Description>
    <p><![CDATA[Line 1
Line 2
Line 3]]></p>
    </PropertyGroup>

    <ItemGroup>
       <i Include="a">
          <m><![CDATA[Line 1
Line 2
Line 3]]></m>
       </i>
    </ItemGroup>

    <Target Name="Build">
        <Message Text="$(Description)" Importance="High"/>
        <Message Text="$(p)" Importance="High"/>

        <Message Text="@(i->'%(m)')" Importance="High"/>
    </Target>
</Project>

@NTaylorMullen NTaylorMullen changed the title Property definition doesn't support CData Property definition that impacts generated AssemblyInfo doesn't support CData Nov 15, 2016
@NTaylorMullen
Copy link
Author

NTaylorMullen commented Nov 15, 2016

Project File (from dotnet new, and then added the description):

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
    <Description><![CDATA[Line 1
Line 2
Line 3]]></Description>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NETCore.App">
      <Version>1.0.1</Version>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Sdk">
      <Version>1.0.0-alpha-20161104-2</Version>
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
  </ItemGroup>

  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Then trying to run results in this:

C:\Users\nimullen\Documents\temp\msbuild> dotnet restore
  Restoring packages for C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj...
  Writing lock file to disk. Path: C:\Users\nimullen\Documents\temp\msbuild\obj\project.assets.json
  Generating MSBuild file C:\Users\nimullen\Documents\temp\msbuild\obj\msbuild.csproj.nuget.g.targets.
  Generating MSBuild file C:\Users\nimullen\Documents\temp\msbuild\obj\msbuild.csproj.nuget.g.props.
  Restore completed in 2436.5539ms for C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj.

  NuGet Config files used:
      C:\Users\nimullen\AppData\Roaming\NuGet\NuGet.Config

  Feeds used:
      https://www.nuget.org/api/v2/
C:\Users\nimullen\Documents\temp\msbuild> dotnet run
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(8,59): error CS1010: Newline in constant [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(8,66): error CS1003: Syntax error, ',' expected [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(9,6): error CS1003: Syntax error, ',' expected [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(9,7): error CS1003: Syntax error, ',' expected [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(10,6): error CS1003: Syntax error, ',' expected [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(10,7): error CS1003: Syntax error, ',' expected [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(10,7): error CS1010: Newline in constant [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(16,69): error CS1026: ) expected [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]
obj\Debug\netcoreapp1.0\msbuild.AssemblyInfo.cs(16,69): error CS1003: Syntax error, ']' expected [C:\Users\nimullen\Documents\temp\msbuild\msbuild.csproj]

The build failed. Please fix the build errors and run again.

On closer inspection it looks like the system is generating the msbuild assembly info file incorrectly. It looks like:

// Generated by the MSBuild WriteCodeFragment class.

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("msbuild")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("Line 1
Line 2
Line 3")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("msbuild")]
[assembly: System.Reflection.AssemblyTitleAttribute("msbuild")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
[assembly: System.Resources.NeutralResourcesLanguageAttribute("en")]

Lastly msbuild version is 15.1.0.0 and dotnet --info:

.NET Command Line Tools (1.0.0-preview4-004079)

Product Information:
 Version:            1.0.0-preview4-004079
 Commit SHA-1 hash:  43dfa6b8ba

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

@rainersigwald must have also tested a property that impacts the assembly info. I've updated the title.

@cdmihai
Copy link
Contributor

cdmihai commented Nov 18, 2016

OK, I can also replicate the bad syntax in the generated AssemblyInfo.

What about the parsing CDATA error inside the actual msbuild file? Is that still an issue for you? If yes, can you please post the project file?

cdmihai added a commit to cdmihai/msbuild that referenced this issue Nov 21, 2016
CodeDom is not not available on .net core, so copy over its string quoting implementation.
Ideally, all this code should be replaced with crossplatform Roselyn

Fixes dotnet#1294
cdmihai added a commit to cdmihai/msbuild that referenced this issue Nov 21, 2016
CodeDom is not available on .net core, so copy over its string quoting implementation.
Ideally, all this code should be replaced with crossplatform Roselyn

Fixes dotnet#1294
@cdmihai cdmihai self-assigned this Nov 21, 2016
cdmihai added a commit to cdmihai/msbuild that referenced this issue Nov 21, 2016
CodeDom is not available on .net core, so copy over its string quoting implementation.
Ideally, all this code should be replaced with crossplatform Roselyn

Fixes dotnet#1294
cdmihai added a commit to cdmihai/msbuild that referenced this issue Nov 21, 2016
CodeDom is not available on .net core, so copy over its string quoting
implementation.
Ideally, all this code should be replaced with crossplatform Roselyn

Fixes dotnet#1294
cdmihai added a commit that referenced this issue Nov 22, 2016
* Mimic Full Framework string quoting

CodeDom is not available on .net core, so copy over its string quoting
implementation.
Ideally, all this code should be replaced with crossplatform Roselyn

Fixes #1294
@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
Projects
None yet
Development

No branches or pull requests

5 participants