@@ -193,18 +193,21 @@ await ReferenceCrawler.CollectAssembliesToDeployAsync(
193
193
Properties . ConfiguredProject ) ;
194
194
195
195
// build a list with the full path for each DLL, referenced DLL and EXE
196
- List < ( string path , string version ) > assemblyList = new List < ( string path , string version ) > ( ) ;
196
+ List < DeploymentAssembly > assemblyList = new List < DeploymentAssembly > ( ) ;
197
197
198
198
foreach ( string assemblyPath in assemblyPathsToDeploy )
199
199
{
200
200
// load assembly to get the version
201
201
var assembly = Assembly . Load ( File . ReadAllBytes ( assemblyPath ) ) . GetName ( ) ;
202
- assemblyList . Add ( ( assemblyPath , $ "{ assembly . Version . ToString ( 4 ) } ") ) ;
202
+ assemblyList . Add ( new DeploymentAssembly ( assemblyPath , $ "{ assembly . Version . ToString ( 4 ) } ") ) ;
203
203
}
204
204
205
205
// if there are referenced project, the assembly list contains repeated assemblies so need to use Linq Distinct()
206
+ // an IEqualityComparer is required implementing the proper comparison
207
+ List < DeploymentAssembly > distinctAssemblyList = assemblyList . Distinct ( new DeploymentAssemblyDistinctEquality ( ) ) . ToList ( ) ;
208
+
206
209
// build a list with the PE files corresponding to each DLL and EXE
207
- List < ( string path , string version ) > peCollection = assemblyList . Distinct ( ) . Select ( a => ( a . path . Replace ( ".dll" , ".pe" ) . Replace ( ".exe" , ".pe" ) , a . version ) ) . ToList ( ) ;
210
+ List < DeploymentAssembly > peCollection = distinctAssemblyList . Select ( a => new DeploymentAssembly ( a . Path . Replace ( ".dll" , ".pe" ) . Replace ( ".exe" , ".pe" ) , a . Version ) ) . ToList ( ) ;
208
211
209
212
var checkAssembliesResult = await CheckNativeAssembliesAvailabilityAsync ( device . DeviceInfo . NativeAssemblies , peCollection ) ;
210
213
if ( checkAssembliesResult != "" )
@@ -217,13 +220,13 @@ await ReferenceCrawler.CollectAssembliesToDeployAsync(
217
220
long totalSizeOfAssemblies = 0 ;
218
221
219
222
// now we will re-deploy all system assemblies
220
- foreach ( ( string path , string version ) peItem in peCollection )
223
+ foreach ( DeploymentAssembly peItem in peCollection )
221
224
{
222
225
// append to the deploy blob the assembly
223
- using ( FileStream fs = File . Open ( peItem . path , FileMode . Open , FileAccess . Read ) )
226
+ using ( FileStream fs = File . Open ( peItem . Path , FileMode . Open , FileAccess . Read ) )
224
227
{
225
228
long length = ( fs . Length + 3 ) / 4 * 4 ;
226
- await outputPaneWriter . WriteLineAsync ( $ "Adding { Path . GetFileNameWithoutExtension ( peItem . path ) } v{ peItem . version } ({ length . ToString ( ) } bytes) to deployment bundle") ;
229
+ await outputPaneWriter . WriteLineAsync ( $ "Adding { Path . GetFileNameWithoutExtension ( peItem . Path ) } v{ peItem . Version } ({ length . ToString ( ) } bytes) to deployment bundle") ;
227
230
byte [ ] buffer = new byte [ length ] ;
228
231
229
232
await fs . ReadAsync ( buffer , 0 , ( int ) fs . Length ) ;
@@ -277,15 +280,15 @@ await ReferenceCrawler.CollectAssembliesToDeployAsync(
277
280
}
278
281
}
279
282
280
- private async System . Threading . Tasks . Task < string > CheckNativeAssembliesAvailabilityAsync ( List < CLRCapabilities . NativeAssemblyProperties > nativeAssemblies , List < ( string path , string version ) > peCollection )
283
+ private async System . Threading . Tasks . Task < string > CheckNativeAssembliesAvailabilityAsync ( List < CLRCapabilities . NativeAssemblyProperties > nativeAssemblies , List < DeploymentAssembly > peCollection )
281
284
{
282
285
string errorMessage = string . Empty ;
283
286
284
287
// loop through each PE to deploy...
285
288
foreach ( var peItem in peCollection )
286
289
{
287
290
// open the PE file and load content
288
- using ( FileStream fs = File . Open ( peItem . path , FileMode . Open , FileAccess . Read ) )
291
+ using ( FileStream fs = File . Open ( peItem . Path , FileMode . Open , FileAccess . Read ) )
289
292
{
290
293
// get PE checksum
291
294
byte [ ] buffer = new byte [ 4 ] ;
@@ -305,7 +308,7 @@ private async System.Threading.Tasks.Task<string> CheckNativeAssembliesAvailabil
305
308
var nativeAssembly = nativeAssemblies . Find ( a => a . Checksum == peChecksum ) ;
306
309
307
310
// check the version now
308
- if ( nativeAssembly . Version . ToString ( 4 ) == peItem . version )
311
+ if ( nativeAssembly . Version . ToString ( 4 ) == peItem . Version )
309
312
{
310
313
// we are good with this one
311
314
continue ;
@@ -323,7 +326,7 @@ private async System.Threading.Tasks.Task<string> CheckNativeAssembliesAvailabil
323
326
exceptionAssemblies . Add ( new CLRCapabilities . NativeAssemblyProperties ( "Windows.Storage.Streams" , 0 , new Version ( ) ) ) ;
324
327
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
325
328
326
- if ( exceptionAssemblies . Exists ( a => a . Name == Path . GetFileNameWithoutExtension ( peItem . path ) ) )
329
+ if ( exceptionAssemblies . Exists ( a => a . Name == Path . GetFileNameWithoutExtension ( peItem . Path ) ) )
327
330
{
328
331
// we are good with this one
329
332
continue ;
@@ -338,7 +341,7 @@ private async System.Threading.Tasks.Task<string> CheckNativeAssembliesAvailabil
338
341
}
339
342
340
343
// no suitable native assembly found present a (hopefully) helpful message to the developer
341
- errorMessage += $ "Couldn't find a valid native assembly required by { Path . GetFileNameWithoutExtension ( peItem . path ) } v{ peItem . version } , checksum 0x{ peChecksum . ToString ( "X8" ) } ." + Environment . NewLine ;
344
+ errorMessage += $ "Couldn't find a valid native assembly required by { Path . GetFileNameWithoutExtension ( peItem . Path ) } v{ peItem . Version } , checksum 0x{ peChecksum . ToString ( "X8" ) } ." + Environment . NewLine ;
342
345
}
343
346
}
344
347
0 commit comments