Getting XML Exception while executing dotnet cyclonedx
Version used: 1.3.0
Exception: Unhandled exception. System.Xml.XmlException: There is no Unicode byte order mar k. Cannot switch to Unicode. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.CheckEncoding(String newEncodingName) at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl) at System.Xml.XmlTextReaderImpl.Read() at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) at NuGet.Packaging.Core.NuspecCoreReaderBase.LoadXml(Stream stream, Boolean l eaveStreamOpen) at NuGet.Packaging.Core.NuspecCoreReaderBase..ctor(Stream stream, Boolean lea veStreamOpen) at NuGet.Packaging.NuspecReader..ctor(Stream stream, IFrameworkNameProvider f rameworkProvider, Boolean leaveStreamOpen) at NuGet.Packaging.NuspecReader..ctor(Stream stream) at CycloneDX.Services.NugetService.GetComponentAsync(String name, String vers ion, String scope) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/Cyclon eDX.Core/Services/NugetService.cs:line 110 at CycloneDX.Services.NugetService.GetComponentAsync(NugetPackage package) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX.Core/Services/Nug etService.cs:line 219 at CycloneDX.Program.OnExecuteAsync() in /home/runner/work/cyclonedx-dotnet/c yclonedx-dotnet/CycloneDX/Program.cs:line 211 at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.I nvokeAsync(MethodInfo method, Object instance, Object[] arguments) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.O nExecute(ConventionContext context, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<
c__DisplayClass0_0.<<Apply>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(S tring[] args, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[T App](CommandLineContext context, CancellationToken cancellationToken) at CycloneDX.Program.Main(String[] args) in /home/runner/work/cyclonedx-dotne t/cyclonedx-dotnet/CycloneDX/Program.cs:line 90 at CycloneDX.Program.<Main>(String[] args)
Can you share any details about the project you are running against? This looks like an issue with a particular package nuspec file.
@coderpatros , Sorry can not share the project details.
Can you tell, what all things I can check at my end to make sure it runs successfully?
I received this error today. I reduced it to a sample project that includes the following packages.config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" targetFramework="net40" />
</packages>
I see the same issue with v2.3.0. My project contains Microsoft.AspNet.Mvc.FixedDisplayModes 1.0.0 like the posted example.
Retrieving Microsoft.AspNet.Mvc.FixedDisplayModes 1.0.0 Unhandled exception. System.Xml.XmlException: There is no Unicode byte order mark. Cannot switch to Unicode. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.CheckEncoding(String newEncodingName) at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl) at System.Xml.XmlTextReaderImpl.Read() at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) at NuGet.Packaging.Core.NuspecCoreReaderBase.LoadXml(Stream stream, Boolean leaveStreamOpen) at NuGet.Packaging.Core.NuspecCoreReaderBase..ctor(Stream stream, Boolean leaveStreamOpen) at CycloneDX.Services.NugetService.GetComponentAsync(String name, String version, Nullable`1 scope) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Services/NugetService.cs:line 290 at CycloneDX.Services.NugetService.GetComponentAsync(NugetPackage package) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Services/NugetService.cs:line 301 at CycloneDX.Program.OnExecuteAsync() in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Program.cs:line 261 at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext() --- End of stack trace from previous location --- at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken) at CycloneDX.Program.Main(String[] args) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Program.cs:line 113 at CycloneDX.Program.<Main>(String[] args)
Also had the same issue as @krisroe. Wondering if any updates.
Retrieving Microsoft.AspNet.Mvc.FixedDisplayModes 1.0.0 Unhandled exception. System.Xml.XmlException: There is no Unicode byte order mark. Cannot switch to Unicode. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res) at System.Xml.XmlTextReaderImpl.CheckEncoding(String newEncodingName) at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl) at System.Xml.XmlTextReaderImpl.Read() at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) at NuGet.Packaging.Core.NuspecCoreReaderBase.LoadXml(Stream stream, Boolean leaveStreamOpen) at NuGet.Packaging.Core.NuspecCoreReaderBase..ctor(Stream stream, Boolean leaveStreamOpen) at NuGet.Packaging.NuspecReader..ctor(Stream stream, IFrameworkNameProvider frameworkProvider, Boolean leaveStreamOpen) at NuGet.Packaging.NuspecReader..ctor(Stream stream) at CycloneDX.Services.NugetService.GetComponentAsync(String name, String version, Nullable`1 scope) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Services/NugetService.cs:line 130 at CycloneDX.Services.NugetService.GetComponentAsync(NugetPackage package) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Services/NugetService.cs:line 300 at CycloneDX.Program.OnExecuteAsync() in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Program.cs:line 261 at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext() --- End of stack trace from previous location --- at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken) at CycloneDX.Program.Main(String[] args) in /home/runner/work/cyclonedx-dotnet/cyclonedx-dotnet/CycloneDX/Program.cs:line 113 at CycloneDX.Program.<Main>(String[] args)
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" targetFramework="net40" /> </packages>
I tried this and couldn't reproduce the issue with version 3.x.x. Probably it was solved by some other change or in a newer version of the NuGet package. If somebody still has this probably you can answer here and I will reopen the issue.