diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs b/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs index 63f307f..eb238e0 100644 --- a/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs +++ b/src/Stratis.VS.SolidityProjectBuildTasks/CompileContracts.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using Microsoft.Build.Framework; @@ -24,25 +25,27 @@ public class CompileContracts : Task public ITaskItem[] Contracts { get; set; } [Required] - public string OutputPath { get; set; } + public string OutputPath { get; set; } + public string BindingsNS { get; set; } = "Ethereum"; public Dictionary Sources => Contracts.ToDictionary(k => k.GetMetadata("Filename"), v => new Source() { Urls = new[] { Path.Combine(v.GetMetadata("RelativeDir"), v.ItemSpec) } }); public override bool Execute() { - if (!File.Exists(Path.Combine(ProjectDir, "node_modules", "solc", "solc.js"))) + if (File.Exists(Path.Combine(ProjectDir, "package.json")) && !File.Exists(Path.Combine(ProjectDir, "node_modules", "solc", "solc.js"))) { Log.LogMessage(MessageImportance.High, "Installing NPM dependencies in project directory {0}...", ProjectDir); var npmoutput = RunCmd("cmd.exe", "/c npm install", ProjectDir); - if (CheckRunCmdError(npmoutput)) + if (!CheckRunCmdError(npmoutput) && CheckRunCmdOutput(npmoutput, "packages audited")) { - Log.LogError("Could not install NPM dependencies: " + GetRunCmdError(npmoutput)); + Log.LogMessage(MessageImportance.High, ((string)npmoutput["stdout"]).Trim()); + } else { - Log.LogMessage(MessageImportance.High, ((string)npmoutput["stdout"]).Trim()); + Log.LogError("Could not install NPM dependencies: " + GetRunCmdError(npmoutput)); } } var solcpath = File.Exists(Path.Combine(ProjectDir, "node_modules", "solc", "solc.js")) ? Path.Combine(ProjectDir, "node_modules", "solc", "solc.js") : @@ -201,7 +204,7 @@ public override bool Execute() } if (cs.evm.gasEstimates != null) { - File.WriteAllText(Path.Combine(outputdir, c.Key + ".gas.txt"), Serialize(cs.evm.gasEstimates)); + File.WriteAllText(Path.Combine(outputdir, c.Key + ".gas.json"), Serialize(cs.evm.gasEstimates)); } if (cs.abi != null) { @@ -227,7 +230,7 @@ public override bool Execute() { if (cs.evm.bytecode._object != null && cs.abi != null) { - if (CheckRunCmdOutput(RunCmd("cmd.exe", $"/c dotnet Nethereum.Generator.Console generate from-abi -abi {Path.Combine(outputdir, c.Key + ".abi")} -bin {Path.Combine(outputdir, c.Key + ".bin")} -o bindings -ns Ethereum", ProjectDir), "")) + if (CheckRunCmdOutput(RunCmd("cmd.exe", $"/c dotnet Nethereum.Generator.Console generate from-abi -abi {Path.Combine(outputdir, c.Key + ".abi")} -bin {Path.Combine(outputdir, c.Key + ".bin")} -o bindings -ns {BindingsNS}", ProjectDir), "")) { Log.LogMessage(MessageImportance.High, $"Created .NET bindings for {c.Key} contract at {Path.Combine(ProjectDir, "bindings", c.Key)}."); } @@ -319,7 +322,6 @@ protected bool InstallNethereumGeneratorToolIfNotPresent() return false; } } - return true; } @@ -368,7 +370,7 @@ public Dictionary RunCmd(string filename, string arguments, stri public bool CheckRunCmdError(Dictionary output) => output.ContainsKey("error") || output.ContainsKey("exception"); public string GetRunCmdError(Dictionary output) => (output.ContainsKey("error") ? (string)output["error"] : "") - + (output.ContainsKey("exception") ? (string)output["exception"] : ""); + + (output.ContainsKey("exception") ? (string)output["exception"] : "" + (output.ContainsKey("stderr") ? (string)output["stderr"] : "")); public bool CheckRunCmdOutput(Dictionary output, string checktext) { @@ -390,6 +392,7 @@ public bool CheckRunCmdOutput(Dictionary output, string checktex { var stderr = (string)output["stderr"]; Log.LogMessage(MessageImportance.High, stderr); + return false; } if (output.ContainsKey("stdout")) { diff --git a/src/Stratis.VS.SolidityProjectBuildTasks/Test.testproj b/src/Stratis.VS.SolidityProjectBuildTasks/Test.testproj index 42544b9..2a86080 100644 --- a/src/Stratis.VS.SolidityProjectBuildTasks/Test.testproj +++ b/src/Stratis.VS.SolidityProjectBuildTasks/Test.testproj @@ -3,7 +3,10 @@ + + TestNS + - + diff --git a/src/Stratis.VS.SolidityProjectTemplate/ProjectType1.ProjectType.solproj b/src/Stratis.VS.SolidityProjectTemplate/ProjectType1.ProjectType.solproj index 48bc435..a9fdf02 100644 --- a/src/Stratis.VS.SolidityProjectTemplate/ProjectType1.ProjectType.solproj +++ b/src/Stratis.VS.SolidityProjectTemplate/ProjectType1.ProjectType.solproj @@ -5,6 +5,7 @@ $soliditycompilerversion$ $solidityconfigfile$ + Ethereum diff --git a/src/Stratis.VS.StratisEVM/BuildSystem/Rules/general.xaml b/src/Stratis.VS.StratisEVM/BuildSystem/Rules/general.xaml index ace44ad..f1d6083 100644 --- a/src/Stratis.VS.StratisEVM/BuildSystem/Rules/general.xaml +++ b/src/Stratis.VS.StratisEVM/BuildSystem/Rules/general.xaml @@ -38,7 +38,13 @@ - + + + + + + + diff --git a/src/Stratis.VS.StratisEVM/BuildSystem/Solidity.targets b/src/Stratis.VS.StratisEVM/BuildSystem/Solidity.targets index ceb8074..cecfc86 100644 --- a/src/Stratis.VS.StratisEVM/BuildSystem/Solidity.targets +++ b/src/Stratis.VS.StratisEVM/BuildSystem/Solidity.targets @@ -17,7 +17,6 @@ - @@ -74,7 +73,7 @@ - + diff --git a/src/Stratis.VS.StratisEVM/SolidityProjectWizardDialogWindow.xaml b/src/Stratis.VS.StratisEVM/SolidityProjectWizardDialogWindow.xaml index 6575566..d3c1c6a 100644 --- a/src/Stratis.VS.StratisEVM/SolidityProjectWizardDialogWindow.xaml +++ b/src/Stratis.VS.StratisEVM/SolidityProjectWizardDialogWindow.xaml @@ -4,7 +4,7 @@ xmlns:vs="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0" Background="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelBrushKey}}" Foreground="{DynamicResource {x:Static vs:ThemedDialogColors.WindowPanelTextBrushKey}}" - SnapsToDevicePixels="True" + SnapsToDevicePixels="False" UseLayoutRounding="True" WindowStartupLocation="CenterOwner" WindowStyle="None" @@ -14,9 +14,9 @@ - Width="500" - Height="200" - MinWidth="500" + Width="452" + Height="184" + MinWidth="462" MinHeight="200"> - - - - - + + + + + - + - + - - - - + + + + + + + + + + + - - - - - - - - - + + - - - - - - - + + + + + + +