diff --git a/.gitignore b/.gitignore index d487996de989..d469a9bfdad7 100644 --- a/.gitignore +++ b/.gitignore @@ -193,4 +193,5 @@ UpgradeLog*.htm # Microsoft Fakes FakesAssemblies/ -.vs/ \ No newline at end of file +.vs/ +/tools/*.dll diff --git a/build.proj b/build.proj index a427049579f6..aa9c8ced86ea 100644 --- a/build.proj +++ b/build.proj @@ -1,22 +1,40 @@ - + + + - .\src\ServiceManagement\Services\Commands\bin - .\src\ServiceManagement\Services\Commands.Test\bin - Microsoft.WindowsAzure.Commands.Test.dll - .\setup\build - .\src\Publish - .\src\Package + $(MSBuildThisFileDirectory) + $(LibraryRoot)src + $(LibraryRoot)tools + $(LibrarySourceFolder)\Publish + $(LibrarySourceFolder)\Package + Debug + false + + false $(PublishDirectory)\Build $(PublishDirectory)\Setup $(PublishDirectory)\TestResults - Configuration=Debug;Platform=Any CPU - Configuration=Release;Platform=Any CPU true @@ -25,6 +43,19 @@ + + + + + $(OnPremiseBuildTasks) + true + false + + + + - @@ -95,13 +121,12 @@ Force nuget package restore so that packages that include .targets files don't need to be checked into source control. --> - - + + + - + --> - + - + Properties="Configuration=$(Configuration);Platform=Any CPU" + BuildInParallel="$(BuildInParallel)" ContinueOnError="false" /> - - - - - - - - - - - - - - - + Properties="Configuration=$(Configuration);Platform=Any CPU" + BuildInParallel="$(BuildInParallel)" ContinueOnError="false" /> + + + + + + - - - + + DependsOnTargets="Clean;Build;Test" /> + + + + + + + + + + + + 31bf3856ad364e35 + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + 31bf3856ad364e35 + + + + - - - - - + + + + + + + + + + false AcceptanceType=CheckIn + - + @@ -252,14 +303,14 @@ + DependsOnTargets="Clean;Build;Test;RunOneSDKCIT" /> + DependsOnTargets="Clean;Build;LiveTestsFilter" /> - + diff --git a/setup-powershellget/Setup/CustomAction.cs b/setup-powershellget/Setup/CustomAction.cs index 4fb665f4daf5..916f0a70211e 100644 --- a/setup-powershellget/Setup/CustomAction.cs +++ b/setup-powershellget/Setup/CustomAction.cs @@ -78,6 +78,7 @@ private static void RunSTAThread(object sessionObject) powerShellShellLink.SetScreenBufferSize(120, 3000); powerShellShellLink.SetWindowSize(120, 50); } + powerShellShellLink.SetFont(); powerShellShellLink.Save(); session.Log("UpdatePSShortcut: success"); } diff --git a/setup-powershellget/Setup/ShellLink.cs b/setup-powershellget/Setup/ShellLink.cs index 8668707bcc4a..80144cca986d 100644 --- a/setup-powershellget/Setup/ShellLink.cs +++ b/setup-powershellget/Setup/ShellLink.cs @@ -435,6 +435,14 @@ public void SetWindowSize(short x, short y) this.consoleProperties.dwWindowSize = c; } + public void SetFont() + { + this.consoleProperties.FaceName = "Lucida Console"; + this.consoleProperties.uFontFamily = 54; + this.consoleProperties.uFontWeight = 400; + this.consoleProperties.uCursorSize = 25; + } + // This does more than console colors private void SetConsoleProperties() { diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 new file mode 100644 index 000000000000..ba35b2cc15c0 --- /dev/null +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -0,0 +1,27 @@ +# ---------------------------------------------------------------------------------- +# +# Copyright Microsoft Corporation +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------------- +[CmdletBinding()] +Param( +[Parameter(Mandatory=$False, HelpMessage="Use Install parameter to install Azure modules from PowerShell Gallery.")] +[switch]$Install +) + +cd c:\ +$welcomeMessage = @" +For a list of all Azure cmdlets type 'help azure'. +For a list of Azure Pack cmdlets type 'Get-Command *wapack*'. +"@ +Write-Output $welcomeMessage + +$VerbosePreference = "Continue" \ No newline at end of file diff --git a/setup-powershellget/azurecmd.wxs b/setup-powershellget/azurecmd.wxs index 4d7330c7bbde..8680059fc809 100644 --- a/setup-powershellget/azurecmd.wxs +++ b/setup-powershellget/azurecmd.wxs @@ -27,14 +27,16 @@ + + - - + + - < "3.0")]]> + < "5.0")]]> @@ -71,15 +73,18 @@ + + + - + + Arguments="-NoExit -ExecutionPolicy Bypass -File "[PowerShellFolder]\ShortcutStartup.ps1""/> @@ -89,16 +94,21 @@ + + + NOT Installed NOT Installed + NOT Installed + NOT Installed diff --git a/setup-powershellget/powershellget.wixproj b/setup-powershellget/powershellget.wixproj index e8bbbb03674c..c3a89824ad39 100644 --- a/setup-powershellget/powershellget.wixproj +++ b/setup-powershellget/powershellget.wixproj @@ -6,7 +6,7 @@ 3.5 {36d6e303-e057-4963-a093-c7aae0fd92b3} 2.0 - AzurePowerShell + AzurePowerShellGet Package $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets diff --git a/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj b/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj index b83b2bb4a746..44f3ed04871c 100644 --- a/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj +++ b/src/Common/Commands.Common.Storage/Commands.Common.Storage.csproj @@ -184,8 +184,4 @@ - - - - \ No newline at end of file diff --git a/src/Common/Commands.Common/Commands.Common.csproj b/src/Common/Commands.Common/Commands.Common.csproj index d78e6a93ba52..cdc01e00f5a1 100644 --- a/src/Common/Commands.Common/Commands.Common.csproj +++ b/src/Common/Commands.Common/Commands.Common.csproj @@ -205,8 +205,4 @@ - - - - \ No newline at end of file diff --git a/src/Common/Commands.ScenarioTests.Common/Commands.ScenarioTests.Common.csproj b/src/Common/Commands.ScenarioTests.Common/Commands.ScenarioTests.Common.csproj index 28c6ed516e94..7e37ef305660 100644 --- a/src/Common/Commands.ScenarioTests.Common/Commands.ScenarioTests.Common.csproj +++ b/src/Common/Commands.ScenarioTests.Common/Commands.ScenarioTests.Common.csproj @@ -170,10 +170,6 @@ - - - - diff --git a/src/Common/Storage/Commands.Storage.ScenarioTest/Commands.Storage.ScenarioTest.csproj b/src/Common/Storage/Commands.Storage.ScenarioTest/Commands.Storage.ScenarioTest.csproj index 5bed436b7312..bdd0e1477fc5 100644 --- a/src/Common/Storage/Commands.Storage.ScenarioTest/Commands.Storage.ScenarioTest.csproj +++ b/src/Common/Storage/Commands.Storage.ScenarioTest/Commands.Storage.ScenarioTest.csproj @@ -241,11 +241,7 @@ - - - - - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/src/Common/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj b/src/Common/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj index 0098437125f3..d1c662acd1c2 100644 --- a/src/Common/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj +++ b/src/Common/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj @@ -278,11 +278,7 @@ - - - - - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/src/Common/Storage/Commands.Storage/Commands.Storage.csproj b/src/Common/Storage/Commands.Storage/Commands.Storage.csproj index 5a2dbe5eda97..1f96ef72944b 100644 --- a/src/Common/Storage/Commands.Storage/Commands.Storage.csproj +++ b/src/Common/Storage/Commands.Storage/Commands.Storage.csproj @@ -316,11 +316,7 @@ - - - - - + powershell.exe -ExecutionPolicy Unrestricted -File "$(ProjectDir)\PostBuild.ps1" "..\..\..\ResourceManager\AzureResourceManager" \ No newline at end of file diff --git a/src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands.ApiManagement.ServiceManagement.csproj b/src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands.ApiManagement.ServiceManagement.csproj index 0c49e6f234e6..adcb747e2c1f 100644 --- a/src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands.ApiManagement.ServiceManagement.csproj +++ b/src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands.ApiManagement.ServiceManagement.csproj @@ -266,10 +266,6 @@ - - - - diff --git a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj index 201afe4d867c..6eb66cc1db04 100644 --- a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj +++ b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/Commands.ApiManagement.Test.csproj @@ -212,10 +212,6 @@ - - - - + \ No newline at end of file diff --git a/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks.sln b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks.sln new file mode 100644 index 000000000000..3060e97842c3 --- /dev/null +++ b/tools/BuildPackagesTask/Microsoft.Azure.Build.Tasks.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Azure.Build.Tasks", "Microsoft.Azure.Build.Tasks.csproj", "{16D89061-2C1E-4E31-B16E-8A7B5B9FF51C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {16D89061-2C1E-4E31-B16E-8A7B5B9FF51C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {16D89061-2C1E-4E31-B16E-8A7B5B9FF51C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {16D89061-2C1E-4E31-B16E-8A7B5B9FF51C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {16D89061-2C1E-4E31-B16E-8A7B5B9FF51C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tools/BuildPackagesTask/Properties/AssemblyInfo.cs b/tools/BuildPackagesTask/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..c05eeeb998a1 --- /dev/null +++ b/tools/BuildPackagesTask/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft.WindowsAzure.Build.Tasks")] +[assembly: AssemblyDescription("Build Tasks")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Microsoft.WindowsAzure.Build.Tasks")] +[assembly: AssemblyCopyright("Copyright © Microsoft Corporation")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] +[assembly: Guid("1fab019b-78ba-4e1b-8f84-d5b72d785f0e")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tools/BuildPackagesTask/RegexReplacementTask.cs b/tools/BuildPackagesTask/RegexReplacementTask.cs new file mode 100644 index 000000000000..6ecc14cf0d2c --- /dev/null +++ b/tools/BuildPackagesTask/RegexReplacementTask.cs @@ -0,0 +1,86 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using System; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace Microsoft.WindowsAzure.Build.Tasks +{ + public class RegexReplacementTask : Task + { + [Required] + public ITaskItem[] Files { get; set; } + + [Required] + public string Find { get; set; } + + [Required] + public string Replace { get; set; } + + public bool LogReplacement { get; set; } + + /// + /// Gets or sets the optional output directory. If a OutputDir value is + /// specified, the original file contents will not be overwritten. + /// + public string OutputDir { get; set; } + + public override bool Execute() + { + try + { + foreach (string fileName in Files.Select(f => f.GetMetadata("FullPath"))) + { + FileAttributes oldAttributes = File.GetAttributes(fileName); + File.SetAttributes(fileName, oldAttributes & ~FileAttributes.ReadOnly); + + string content = Regex.Replace( + File.ReadAllText(fileName), + Find, + Replace); + + string outputFileName = fileName; + string message = null; + if (!string.IsNullOrEmpty(OutputDir)) + { + string path = Path.GetFullPath(OutputDir); + outputFileName = Path.Combine(path, Path.GetFileName(fileName)); + message = " saved as " + outputFileName; + } + + File.WriteAllText(outputFileName, content, Encoding.UTF8); + File.SetAttributes(outputFileName, oldAttributes); + + if (LogReplacement) + { + Log.LogMessage("Processed regular expression replacement in file {0}{1}", fileName, message); + } + } + + return true; + } + catch (Exception ex) + { + Log.LogErrorFromException(ex); + return false; + } + } + } +} diff --git a/tools/BuildPackagesTask/StrongNameUtility.cs b/tools/BuildPackagesTask/StrongNameUtility.cs new file mode 100644 index 000000000000..e21d78401bdd --- /dev/null +++ b/tools/BuildPackagesTask/StrongNameUtility.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace Microsoft.WindowsAzure.Build.Tasks +{ + /// + /// Utility class for managing the Process used to work with the sn.exe + /// tool in the Windows SDK. + /// + internal class StrongNameUtility + { + private string _snPath; + + public StrongNameUtility() + { + } + + public bool ValidateStrongNameToolExistance(string windowsSdkPath) + { + // Location the .NET strong name signing utility + _snPath = FindFile(windowsSdkPath, "sn.exe"); + if (_snPath == null) + { + return false; + } + + return true; + } + + public bool Execute(string arguments, out string output) + { + int exitCode; + output = null; + + ProcessStartInfo processInfo = new ProcessStartInfo(_snPath) + { + Arguments = arguments, + UseShellExecute = false, + RedirectStandardOutput = true, + }; + + using (Process process = Process.Start(processInfo)) + { + output = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + + exitCode = process.ExitCode; + } + + return exitCode == 0; + } + + private static string FindFile(string path, string filenameOfInterest) + { + foreach (string d in Directory.GetDirectories(path)) + { + var result = Directory.GetFiles(d, filenameOfInterest).FirstOrDefault(); + if (result != null) + { + return result; + } + + return FindFile(d, filenameOfInterest); + } + + return null; + } + } +} diff --git a/tools/BuildPackagesTask/ValidateStrongNameSignatureTask.cs b/tools/BuildPackagesTask/ValidateStrongNameSignatureTask.cs new file mode 100644 index 000000000000..d75bdc9d9269 --- /dev/null +++ b/tools/BuildPackagesTask/ValidateStrongNameSignatureTask.cs @@ -0,0 +1,147 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.WindowsAzure.Build.Tasks +{ + /// + /// A simple Microsoft Build task for validating the strong name signature + /// on a .NET assembly. + /// + public class ValidateStrongNameSignatureTask : Task + { + /// + /// Gets or sets the path to the Windows SDK on the machine. + /// + [Required] + public string WindowsSdkPath { get; set; } + + /// + /// Gets or sets the assembly whose strong name needs to be verified. + /// + [Required] + public ITaskItem Assembly { get; set; } + + /// + /// Gets or sets the expected strong name token for the assembly. + /// + [Required] + public string ExpectedTokenSignature { get; set; } + + /// + /// Gets or sets a value indicating whether the assembly is expected to + /// be delay signed. + /// + public bool ExpectedDelaySigned { get; set; } + + /// + /// Executes the task to validate the strong name information for the + /// assembly using the input values expected by the task. + /// + /// Returns a value indicating whether the task has been + /// successful and the build should continue. + public override bool Execute() + { + try + { + StrongNameUtility utility = new StrongNameUtility(); + if (!utility.ValidateStrongNameToolExistance(WindowsSdkPath)) + { + Log.LogError("The strong name tool (sn.exe) could not be located within the Windows SDK directory structure ({0})).", WindowsSdkPath); + return false; + } + + string path = Assembly.ItemSpec; + + // Check the public key token of the assembly. + // -q -T: Display token for public key. + string output; + string arguments = "-q -T \"" + path + "\""; + bool success = utility.Execute(arguments, out output); + + if (!success) + { + Log.LogError("The assembly \"" + path + "\" has not been strong named signed."); + Log.LogError(output); + + return false; + } + + // Read the public key token. + int lastSpace = output.LastIndexOf(' '); + if (lastSpace >= 0) + { + output = output.Substring(lastSpace + 1).Trim(); + } + + if (output != ExpectedTokenSignature) + { + Log.LogError("The assembly \"{0}\" had the strong name token of \"{1}\", but was expected to have the token \"{2}\"", + path, + output, + ExpectedTokenSignature); + return false; + } + + Log.LogMessage("The assembly \"{0}\" had the expected strong name token of \"{1}\"", + path, + output); + + // Validate that it is or is not delay signed. + // -q -v[f]: Verify for strong name signature self + // consistency. If -vf is specified, force verification even if + // disabled in the registry. + output = null; + arguments = "-q -vf \"" + path + "\""; + success = utility.Execute(arguments, out output); + + success = (success == (!ExpectedDelaySigned)); + + string message; + if (ExpectedDelaySigned && success || !ExpectedDelaySigned && !success) + { + message = "The assembly \"{0}\" was delay signed."; + } + else if (ExpectedDelaySigned && !success) + { + message = "The assembly \"{0}\" was not delay signed."; + } + else + { + message = "The assembly \"{0}\" has been fully signed."; + } + + if (success) + { + Log.LogMessage(MessageImportance.High, message, path); + } + else + { + Log.LogError(message, path); + } + + return success; + } + catch (Exception ex) + { + Log.LogErrorFromException(ex); + return false; + } + } + } +}