@@ -41,6 +41,14 @@ public class InstallWorkloadFromArtifacts : Task
4141
4242 private const string s_nugetInsertionTag = "<!-- TEST_RESTORE_SOURCES_INSERTION_LINE -->" ;
4343 private string AllManifestsStampPath => Path . Combine ( SdkWithNoWorkloadInstalledPath , ".all-manifests.stamp" ) ;
44+ private static readonly string [ ] s_manifestIds = new [ ]
45+ {
46+ "microsoft.net.workload.mono.toolchain" ,
47+ "microsoft.net.workload.emscripten.net6" ,
48+ "microsoft.net.workload.emscripten.net7" ,
49+ "microsoft.net.workload.mono.toolchain.net6" ,
50+ "microsoft.net.workload.mono.toolchain.net7"
51+ } ;
4452
4553 public override bool Execute ( )
4654 {
@@ -146,6 +154,8 @@ private bool InstallAllManifests()
146154 return true ;
147155 }
148156
157+ ExecuteHackForInstallerMismatch ( ) ;
158+
149159 string nugetConfigContents = GetNuGetConfig ( ) ;
150160 HashSet < string > manifestsInstalled = new ( ) ;
151161 foreach ( ITaskItem workload in WorkloadIds )
@@ -175,6 +185,43 @@ private bool InstallAllManifests()
175185 File . WriteAllText ( AllManifestsStampPath , string . Empty ) ;
176186
177187 return true ;
188+
189+ void ExecuteHackForInstallerMismatch ( )
190+ {
191+ // HACK - because sdk doesn't yet have the version-less manifest names in the known
192+ // workloads list
193+ string ? txtPath = Directory . EnumerateFiles ( Path . Combine ( SdkWithNoWorkloadInstalledPath , "sdk" ) , "IncludedWorkloadManifests.txt" ,
194+ new EnumerationOptions { RecurseSubdirectories = true , MaxRecursionDepth = 2 } )
195+ . FirstOrDefault ( ) ;
196+ if ( txtPath is null )
197+ throw new LogAsErrorException ( $ "Could not find IncludedWorkloadManifests.txt in { SdkWithNoWorkloadInstalledPath } ") ;
198+
199+ string stampPath = Path . Combine ( Path . GetDirectoryName ( txtPath ) ! , ".stamp" ) ;
200+ if ( File . Exists ( stampPath ) )
201+ return ;
202+
203+ List < string > lines = File . ReadAllLines ( txtPath ) . ToList ( ) ;
204+ int originalCount = lines . Count ;
205+
206+ // we want to insert the manifests in a fixed order
207+ // so first remove all of them
208+ foreach ( string manifestId in s_manifestIds )
209+ lines . Remove ( manifestId ) ;
210+ // .. and then insert
211+ lines . AddRange ( s_manifestIds ) ;
212+
213+ // currently using emscripten.net7 instead of this,
214+ // so remove it from the list
215+ lines . Remove ( "microsoft.net.workload.emscripten" ) ;
216+
217+ if ( lines . Count != originalCount )
218+ {
219+ // Update the file only if we are making any changes
220+ File . WriteAllText ( txtPath , string . Join ( Environment . NewLine , lines ) ) ;
221+ }
222+
223+ File . WriteAllText ( stampPath , "" ) ;
224+ }
178225 }
179226
180227 private bool InstallPacks ( InstallWorkloadRequest req , string nugetConfigContents )
0 commit comments