Error: Collection was modified

ClassLibrary6.zip (5.6 KB)

bugs://E25963 was closed as fixed.

1 Like

Hello again,
in relation with bugs://E25963 ive tested the last available build 11.0.0.2755. and have found some new problems with the project file conversion:

  1. The biggest problem is that the conversion de-entitize xml special characters
Condition="$(TEAFVersion)>=2000 AND $(TEAFVersion)<=2200"  
converts to 
Condition="$(TEAFVersion)>=2000 AND $(TEAFVersion)<=2200"

which results in: error : '<', hexadecimal value 0x3C, is an invalid attribute character. Line 65, position 94. on project load.

  1. Problem is thaht the NugetRepository converts incorrectly and build throws:
Unhandled Exception:Items that are outside Target elements must have one of the following operations: Include, Update, or Remove.  
Error: Items that are outside Target elements must have one of the following operations: Include, Update, or Remove.

Before conversion:

</PropertyGroup> 
 <RestoreAdditionalProjectSources>https://nuget.tescosw.loc/nuget</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BimToolRefs" Version="1.0.5">
	<ExcludeAssets>runtime</ExcludeAssets>
    <PrivateAssets>contentfiles;analyzers</PrivateAssets>
</PackageReference>
<PackageReference Include="CadToolRefs" Version="1.0.5">
	<ExcludeAssets>runtime</ExcludeAssets>
    <PrivateAssets>contentfiles;analyzers</PrivateAssets>
</PackageReference>
</ItemGroup>

converts to

<ItemGroup>
    <NuGetReference Include="BimToolRefs:[1.0.5]" />
    <NuGetReference Include="CadToolRefs:[1.0.5]" />
    <NugetRepository>https://nuget.tescosw.loc/nuget</NugetRepository>
  </ItemGroup>

where the nugetrepository is outside the NugetReference Item, which is also not good according to the documentation Package References (elementscompiler.com)

  1. problem is that i think, the conversion of PackageReferences should not happen if the project imports RemObjects.Elements.Echoes.Legacy.targets, are the NuGetReference implemented within the Legacy.targets ? For me this appears as non-legacy stuff.

This is with Legacy target? projects with Legacy target should not convert — but IIRC that issue was logged last week but is still open…

that said

this conversion is wrong indeed, it should use Include.

Logged as bugs://E26011. for NuGetRepository missing the Include

Logged as bugs://E26012. for the migration of Legacy (jic this got missed between the other issues)

Thanks for the sumup. And the de-enititization is not considered as bug ?

I don’t believe so; < and > are valid inside XML attributes.

From MSBuild Conditions - Visual Studio 2015 | Microsoft Docs

<, >, <=, >= Evaluates the numeric values of the operands. Returns true if the relational evaluation is true. Operands must evaluate to a decimal or hexadecimal number. Hexadecimal numbers must begin with “0x”. Note: In XML, the characters < and > must be escaped.

That’s not XML rules, that might be MSBuild’s rules

Okay.

bugs://E26011 was closed as fixed.

Sadly i have two new issues with the latest 11.0.0.2757 version and the project file migration in VS 2019:

  1. Problem After migration - Visual studio cannot open the project files: throws error : The specified path format is not supported. (translated)
    Simplified tescase scenario:
    Step1: Create new project "Class Library (Classic .NET) (RemObjectsOxygene)
    Step2: Edit the creted .elements file and add <RestoreAdditionalProjectSources>https://nuget.tescosw.loc/nuget</RestoreAdditionalProjectSources> to the first PropertyGroup. (this forces the conversion to happen, simmulates the situation in our projects)
    Step3: Reload the project in Visal Studio - it wont load and starts throwing errors. The specified path format is not supported. (translated)

  2. Problem: ProjectGuid migrates to uppercase but the ProjectReference stays lowercase

<ProjectGuid>{b4141930-1990-5be0-4906-9bc3a33888a8}</ProjectGuid>
migrates to
<ProjectGuid>{B4141930-1990-5BE0-4906-9BC3A33888A8}</ProjectGuid>

but

 <ProjectReference Include="..\GEN\GEN.elements">
      <Name>GEN</Name>
      <Project>{1216cb58-5f0e-c867-966b-be20c5c8ff26}</Project>
    </ProjectReference>

remains lowercase even the referenced project is also migrated within the same solution open. Dont know if that really matters because i cant get through the problem 1 which is a showstopper currently.

No migration - best migration. Bug E26012

I don’t think this should be an issue? GUIDs are not case-sensitive.

Can i see the/a original projecgt, as well as the broken one?

3 docs:
AfterCreate is the fresh project created by the new project wizard.
AfterModification is fresh project with the restoreAdditionalProjectSources tag added manually
AfterMigration is result of VS migration of AfterModification file on solution open.
ClassLibrary1.AfterCreate.elements (2.3 KB)
ClassLibrary1.AfterModification.elements (2.4 KB)
ClassLibrary1.AfterMigration(failing).elements (2.3 KB)

1 Like

Can you change NugetRepository to NuGetRepository, uppercase G.

Yes that helps.

Great. this was a bug in the migration code, it used the wrong case, and these tags are case sensitive. It seems VS really didn’t like having what it thought was a normal file, with a http URL as filename ;).

Production testing brings always new discoveries.

1 Like