@@ -97,6 +97,9 @@ public async Task DeployAsync(CancellationToken cancellationToken, TextWriter ou
97
97
// this result is of type Microsoft.Build.Evaluation.Project
98
98
var projectResult = await ( ( System . Threading . Tasks . Task < Microsoft . Build . Evaluation . Project > ) buildProject . GetValue ( Properties . ConfiguredProject ) ) ;
99
99
100
+ // All the files that needs potentially to be deployed to the internal storage
101
+ var contents = projectResult . Items . Where ( m => m . ItemType == "Content" && m . Metadata . Any ( t => t . Name == "CopyToOutputDirectory" && t . EvaluatedValue != "Never" ) ) ;
102
+
100
103
if ( ! string . Equals ( projectResult . Properties . First ( p => p . Name == "OutputType" ) . EvaluatedValue , "Exe" , StringComparison . InvariantCultureIgnoreCase ) )
101
104
{
102
105
// This is not an executable project, it must be a referenced assembly
@@ -375,6 +378,47 @@ await Task.Run(async delegate
375
378
// deployment successful
376
379
await outputPaneWriter . WriteLineAsync ( "Deployment successful!" ) ;
377
380
381
+ // Now deploying to the internal storage if any
382
+ if ( contents . Any ( ) )
383
+ {
384
+ await outputPaneWriter . WriteLineAsync ( $ "Deploying { contents . Count ( ) } content files to internal storage") ;
385
+ MessageCentre . InternalErrorWriteLine ( "Deploying content files to internal storage" ) ;
386
+ foreach ( var file in contents )
387
+ {
388
+ string fileName ;
389
+ var storPath = file . Metadata . Where ( m => m . Name == "NF_StoragePath" ) ;
390
+ if ( storPath . Any ( ) )
391
+ {
392
+ fileName = storPath . FirstOrDefault ( ) . EvaluatedValue ;
393
+ }
394
+ else
395
+ {
396
+ // Default is internal storage
397
+ fileName = "I:\\ " + file . EvaluatedInclude ;
398
+ }
399
+
400
+ await outputPaneWriter . WriteLineAsync ( $ "{ file . EvaluatedInclude } deploying to { fileName } .") ;
401
+ MessageCentre . InternalErrorWriteLine ( $ "{ file . EvaluatedInclude } deploying to { fileName } .") ;
402
+
403
+ // Find the file where the exe is. There is an exe because otherwise, we won't be here with a simple DLL
404
+ var fileAssemblyPath = projectResult . Properties . Where ( m => m . Name == "TargetPath" ) . First ( ) . EvaluatedValue ;
405
+ var contentFileName = Path . Combine ( fileAssemblyPath . Substring ( 0 , fileAssemblyPath . LastIndexOf ( Path . DirectorySeparatorChar ) ) , file . EvaluatedInclude ) ;
406
+
407
+ // Deploying the file
408
+ var ret = device . DebugEngine . AddStorageFile ( fileName , File . ReadAllBytes ( contentFileName ) ) ;
409
+ if ( ret == Debugger . WireProtocol . StorageOperationErrorCode . NoError )
410
+ {
411
+ await outputPaneWriter . WriteLineAsync ( $ "{ file . EvaluatedInclude } deplpoyed sucessfully.") ;
412
+ MessageCentre . InternalErrorWriteLine ( $ "{ file . EvaluatedInclude } deplpoyed sucessfully.") ;
413
+ }
414
+ else
415
+ {
416
+ await outputPaneWriter . WriteLineAsync ( $ "{ file . EvaluatedInclude } deployment error.") ;
417
+ MessageCentre . InternalErrorWriteLine ( $ "{ file . EvaluatedInclude } deployment error.") ;
418
+ }
419
+ }
420
+ }
421
+
378
422
// reset the hash for the connected device so the deployment information can be refreshed
379
423
deviceExplorer . LastDeviceConnectedHash = 0 ;
380
424
}
0 commit comments