Closed
Description
Description
In this optimization change (XmlBaseWriter.cs), there is a mistake which changes the logic in the XmlBaseWriter.cs
. Previously, it checked for the existence of -
at the end of a text, but now it is checked at the beginning of the text.
Reproduction Steps
Use .NET 7 preview 1
and run this command for any F# project:
dotnet msbuild /t:build /pp /p:TargetFramework=net7.0 MyFsharpProject.fsharp
It fails to write for example this element (which exists there for about 5 years)
Expected behavior
Shouldn't throw an exception
Actual behavior
throws an exception:
System.ArgumentException: An XML comment cannot contain '--', and '-' cannot be the last character.
at System.Xml.XmlTextWriter.WriteComment(String text)
at System.Xml.XmlElement.WriteElementTo(XmlWriter writer, XmlElement el)
at System.Xml.XmlDocument.Save(XmlWriter w)
at Microsoft.Build.Evaluation.Project.ProjectImpl.SaveLogicalProject(TextWriter writer)
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsNotAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, String[] inputResultsCaches, String outputResultsCache, String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Unhandled exception: System.ArgumentException: An XML comment cannot contain '--', and '-' cannot be the last character.
at System.Xml.XmlTextWriter.WriteComment(String text)
at System.Xml.XmlElement.WriteElementTo(XmlWriter writer, XmlElement el)
at System.Xml.XmlDocument.Save(XmlWriter w)
at Microsoft.Build.Evaluation.Project.ProjectImpl.SaveLogicalProject(TextWriter writer)
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, Dictionary`2 restoreProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, TextWriter targetsWriter, Boolean detailedSummary, ISet`1 warningsAsErrors, ISet`1 warningsNotAsErrors, ISet`1 warningsAsMessages, Boolean enableRestore, ProfilerLogger profilerLogger, Boolean enableProfiler, Boolean interactive, Boolean isolateProjects, GraphBuildOptions graphBuildOptions, Boolean lowPriority, String[] inputResultsCaches, String outputResultsCache, String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
at Microsoft.DotNet.Cli.Utils.MSBuildForwardingAppWithoutLogging.ExecuteInProc(String[] arguments)
Regression?
yes
Known Workarounds
no
Configuration
No response