Skip to content

Commit

Permalink
adjusting for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellerbach committed Mar 22, 2024
1 parent a9319e2 commit 351c4a6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageManifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/VisualStudio/ImageManifestSchema/2014">
<Symbols>
<String Name="Resources" Value="/nanoFramework.Tools.VS2022.Extension;v2022.3.0.70;C78BE3280FBDE583;Component/Resources" />
<String Name="Resources" Value="/nanoFramework.Tools.VS2022.Extension;v2022.3.0.77;C78BE3280FBDE583;Component/Resources" />
<Guid Name="NanoFrameworkCatalog" Value="{23cf437f-5e0e-4b0c-8aa4-ceec5b5f8679}" />
<ID Name="DeviceConnected" Value="20" />
<ID Name="DeviceDisconnected" Value="30" />
Expand Down
11 changes: 10 additions & 1 deletion VisualStudio.Extension-2022/Rules/None.BrowseObject.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,14 @@

<BoolProperty Name="Visible"
Visible="false" />

<!--nanoFramework deployment rule-->
<Category Name="nanoFramework" DisplayName="nanoFramework" Description=".NET nanoFramework properties" />
<StringProperty Category="nanoFramework" Name="NF_StoragePath" DisplayName="Storage destination path" Visible="true" Description="Destination path in target storage, including file name.">
<StringProperty.DataSource>
<DataSource HasConfigurationCondition="False"
PersistedName="NF_StoragePath"
Persistence="UserFile"
SourceOfDefaultValue="AfterContext" />
</StringProperty.DataSource>
</StringProperty>
</Rule>
18 changes: 18 additions & 0 deletions VisualStudio.Extension-2022/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,24 @@
"Microsoft.VisualStudio.Interop": "17.5.33428.366"
}
},
"csharp.assemblyinfotemplate": {
"type": "Project"
},
"csharp.blankapplication-vs2022": {
"type": "Project"
},
"csharp.classlibrary-vs2022": {
"type": "Project"
},
"csharp.classtemplate": {
"type": "Project"
},
"csharp.resourcetemplate": {
"type": "Project"
},
"csharp.testapplication-vs2022": {
"type": "Project"
},
"nanoFramework.Tools.BuildTasks": {
"type": "Project",
"dependencies": {
Expand Down
3 changes: 3 additions & 0 deletions nanoFramework.Tools.VisualStudio.sln
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ Global
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
CSharp.TestApplication\CSharp.TestApplication.Shared.projitems*{0a06b3c4-5813-439e-85ef-6d584a4e03ed}*SharedItemsImports = 13
nf-debugger\nanoFramework.Tools.DebugLibrary.Shared\nanoFramework.Tools.DebugLibrary.Net.projitems*{101d57ad-d22f-4905-a992-de15e723f164}*SharedItemsImports = 5
CSharp.TestApplication\CSharp.TestApplication.Shared.projitems*{3040ba82-56cc-4189-a26c-cabb4b6b7b87}*SharedItemsImports = 4
nf-debugger\nanoFramework.Tools.DebugLibrary.Shared\nanoFramework.Tools.DebugLibrary.Net.projitems*{31472cae-4b1a-4ab9-9b2a-8f28dbe01bcf}*SharedItemsImports = 13
CSharp.ClassLibrary\CSharp.ClassLibrary.Shared.projitems*{4aa9a693-ff7c-4f84-b0ce-28a7ee009471}*SharedItemsImports = 4
CSharp.BlankApplication\CSharp.BlankApplication.Shared.projitems*{572121bd-e972-4bf7-abf1-78251dde1181}*SharedItemsImports = 4
CSharp.ClassLibrary\CSharp.ClassLibrary.Shared.projitems*{5dc66510-7529-477b-98a8-733a792ddd14}*SharedItemsImports = 4
Expand All @@ -303,6 +305,7 @@ Global
vs-extension.shared\vs-extension.shared.projitems*{b16737e2-4b5d-4048-a740-2bb1df462637}*SharedItemsImports = 13
CSharp.BlankApplication\CSharp.BlankApplication.Shared.projitems*{c5a2cf84-5591-4c33-8cf7-6c949531bfb1}*SharedItemsImports = 13
CSharp.BlankApplication\CSharp.BlankApplication.Shared.projitems*{cd034c5a-a9eb-4c8e-b163-0ba9619cd122}*SharedItemsImports = 4
metadata-processor\MetadataProcessor.Shared\MetadataProcessor.Shared.projitems*{e32f7d15-2499-440c-8026-4d5ee1c5ec3a}*SharedItemsImports = 4
vs-extension.shared\vs-extension.shared.projitems*{e3e5b359-8e18-4b7d-8469-f93c6867d712}*SharedItemsImports = 4
CSharp.ClassLibrary\CSharp.ClassLibrary.Shared.projitems*{faa194f0-5c3b-46c7-977b-d2a84444bf80}*SharedItemsImports = 13
EndGlobalSection
Expand Down
35 changes: 27 additions & 8 deletions vs-extension.shared/DeployProvider/DeployProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,22 +375,41 @@ await Task.Run(async delegate
// Now deploying to the internal storage if any
if (contents.Any())
{
await outputPaneWriter.WriteLineAsync($"Deploying {contents.Count()} content files to internal storage");
MessageCentre.InternalErrorWriteLine("Deploying content files to internal storage");
foreach(var file in contents)
foreach (var file in contents)
{
MessageCentre.InternalErrorWriteLine($"Deploying {file.EvaluatedInclude}");
if(file.EvaluatedInclude.Contains(Path.DirectorySeparatorChar))
string fileName;
var storPath = file.Metadata.Where(m => m.Name == "NF_StoragePath");
if (storPath.Any())
{
MessageCentre.InternalErrorWriteLine("File should not be a path, internal storage does not support folders. It will still try to deploy.");
fileName = storPath.FirstOrDefault().EvaluatedValue;
}
else
{
// Default is internal storage
fileName = "I:\\" + file.EvaluatedInclude;
}

await outputPaneWriter.WriteLineAsync($"{file.EvaluatedInclude} deploying to {fileName}.");
MessageCentre.InternalErrorWriteLine($"{file.EvaluatedInclude} deploying to {fileName}.");

// Find the file where the exe is. There is an exe because otherwise, we won't be here with a simple DLL
var fileAssemblyPath = projectResult.Properties.Where(m => m.Name == "TargetPath").First().EvaluatedValue;
var fileName = Path.Combine(fileAssemblyPath.Substring(0, fileAssemblyPath.LastIndexOf(Path.DirectorySeparatorChar)), file.EvaluatedInclude);
var contentFileName = Path.Combine(fileAssemblyPath.Substring(0, fileAssemblyPath.LastIndexOf(Path.DirectorySeparatorChar)), file.EvaluatedInclude);

// Deploying the file
// var ret = device.DebugEngine.AddFile("I:\\" + fileName, File.ReadAllBytes(fileName));
// Checking success :TODO once Debug lib will be updated
// MessageCentre.InternalErrorWriteLine($"");
var ret = device.DebugEngine.AddStorageFile(fileName, File.ReadAllBytes(contentFileName));
if (ret == Debugger.WireProtocol.StorageOperationErrorCode.NoError)
{
await outputPaneWriter.WriteLineAsync($"{file.EvaluatedInclude} deplpoyed sucessfully.");
MessageCentre.InternalErrorWriteLine($"{file.EvaluatedInclude} deplpoyed sucessfully.");
}
else
{
await outputPaneWriter.WriteLineAsync($"{file.EvaluatedInclude} deployment error.");
MessageCentre.InternalErrorWriteLine($"{file.EvaluatedInclude} deployment error.");
}
}
}

Expand Down

0 comments on commit 351c4a6

Please sign in to comment.