TryParseOldStyleProjects throws "Sequence contains more than one element" when ASP.NET project contains project references
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start in IISExpressLaunchDetailsExtensions.TryParseOldStyleProjects, where the old-style csproj XML is loaded and the Project element is selected. Reproduce with an ASP.NET Framework project containing a referenced class library and no launchProfile.json; done means AddIISExpressProject no longer throws and the old project metadata is parsed successfully.
Written by the indexing model from the issue text.
Description
Describe the bug
AddIISExpressProject from Aspire.Hosting.IncrementalMigration will throw an InvalidOperationException ("Sequence contains more than one element") if the referenced ASP.NET project itself contains project reference (which would be all but the most simple sites) and a launchProfile.json doesn't exist (i.e. reading from the old-style csproj itself).
In IISExpressLaunchDetailsExtensions.TryParseOldStyleProjects, after the csproj is loaded as an xml document, an attempt to grab the root <Project> is made (doc.Descendants(MsbuildNS + "Project").SingleOrDefault()). However Descendants grabs all <Project> nodes, which includes those that are children of <ProjectReference>, which trips the SingleOrDefault.
To Reproduce
Create a class library project and add it as a project reference to the ASP.NET Framework project referenced by the Aspire AppHost.
This repo+branch also reproduced the issue:
https://github.com/Sebbs128/AspireNetFramework/tree/update-to-swa-hosting-package
Exceptions (if any)
System.InvalidOperationException 'Sequence contains more than one element'
Stacktrace
at System.Linq.ThrowHelper.ThrowMoreThanOneElementException()
at System.Linq.Enumerable.TryGetSingle[TSource](IEnumerable`1 source, Boolean& found)
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at Aspire.Hosting.IISExpressLaunchDetailsExtensions.TryParseOldStyleProject(String path, IISExpressLaunchDetails& metadata)
at Aspire.Hosting.IISExpressLaunchDetailsExtensions.GetLaunchDetails(IProjectMetadata metadata)
at Aspire.Hosting.IISExpressProjectExtensions.AddIISExpressProject[TProject](IDistributedApplicationBuilder builder, String name)
at Program.<Main>$(String[] args) in D:\\source\\AspireNetFramework\\samples\\AspireNetFramework.Samples.AppHost\\Program.cs:line 9
Further technical details
Please include the following if applicable:
ASP.NET Framework Application:
- Technologies and versions used (i.e. MVC/WebForms/etc): MVC
- .NET Framework Version: 4.8
- IIS Version: IISExpress 10.0.26013.1000
- Windows Version: Windows 11 (100.22621)
ASP.NET Core Application:
- Targeted .NET version: 10
- .NET SDK version: 10.0.300
- Dominant language
- C#
- Stars
- 384
- Forks
- 76
- Avg merge
- 2h 24m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/systemweb-adapters
-
Needs: Triage :mag:
Difficulty 4/5 3-5 days Newbie friendliness 63/100
dotnet/systemweb-adapters#698 · 2 comments ·
-
Needs: Triage :mag:
Difficulty 4/5 3-5 days Newbie friendliness 45/100
dotnet/systemweb-adapters#697 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
dotnet/systemweb-adapters#687 ·
-
up for grabs
Difficulty 3/5 1-2 days Newbie friendliness 55/100
dotnet/systemweb-adapters#684 · 3 comments ·
-
up for grabs
Difficulty 3/5 1-2 days Newbie friendliness 55/100
dotnet/systemweb-adapters#683 · 3 comments · 1 reaction ·
All issues in dotnet/systemweb-adapters
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·