Skip to content

[#103630146] Added powershellget.sln and regenerated wix file for powershell.sln #927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<AzureResourceManagerSln Include=".\src\ResourceManager.sln" />
<AzureServiceManagementSln Include=".\src\ServiceManagement.sln" />
<SetupSln Include=".\setup\azurepowershell.sln" />
<SetupPowershellGetSln Include=".\setup-powershellget\powershellget.sln" />
</ItemGroup>

<UsingTask
Expand Down Expand Up @@ -160,11 +161,16 @@
Importance="high"
Text="You are required to have installed the WiX Toolset at http://wix.codeplex.com/releases/view/115492 (Wix38.msi)"
ContinueOnError="false" />
<!--<MSBuild
<MSBuild
Projects="@(SetupPowershellGetSln)"
Targets="Build"
Properties="$(DebugBuildConfig)"
ContinueOnError="false" />
<MSBuild
Projects="@(SetupSln)"
Targets="Build"
Properties="$(DebugBuildConfig)"
ContinueOnError="false" />-->
ContinueOnError="false" />
</Target>

<!-- Build the Setup -->
Expand All @@ -177,11 +183,16 @@
Importance="high"
Text="You are required to have installed the WiX Toolset at http://wix.codeplex.com/releases/view/115492 (Wix38.msi)"
ContinueOnError="false" />
<!--<MSBuild
<MSBuild
Projects="@(SetupPowershellGetSln)"
Targets="Build"
Properties="$(ReleaseBuildConfig)"
ContinueOnError="false" />
<MSBuild
Projects="@(SetupSln)"
Targets="Build"
Properties="$(ReleaseBuildConfig)"
ContinueOnError="false" />-->
ContinueOnError="false" />
</Target>

<!-- Build the Cmdlets and Setup in all configurations -->
Expand Down
32 changes: 32 additions & 0 deletions setup-powershellget/Setup/CustomAction.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">

<!--
Use supportedRuntime tags to explicitly specify the version(s) of the .NET Framework runtime that
the custom action should run on. If no versions are specified, the chosen version of the runtime
will be the "best" match to what Microsoft.Deployment.WindowsInstaller.dll was built against.

WARNING: leaving the version unspecified is dangerous as it introduces a risk of compatibility
problems with future versions of the .NET Framework runtime. It is highly recommended that you specify
only the version(s) of the .NET Framework runtime that you have tested against.

Note for .NET Framework v3.0 and v3.5, the runtime version is still v2.0.

In order to enable .NET Framework version 2.0 runtime activation policy, which is to load all assemblies
by using the latest supported runtime, @useLegacyV2RuntimeActivationPolicy="true".

For more information, see http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx
-->

<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727"/>

</startup>

<!--
Add additional configuration settings here. For more information on application config files,
see http://msdn.microsoft.com/en-us/library/kza1yk3a.aspx
-->

</configuration>
109 changes: 109 additions & 0 deletions setup-powershellget/Setup/CustomAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.WindowsAzure.Setup
{
using System;
using System.IO;
using Deployment.WindowsInstaller;
using System.Threading;

public class CustomAction
{
// The exception object which will store (if) exception which is occured in our sta thread
private static Exception _STAThreadException;

private static uint[] powerShellDefaultColorTable = new uint[]
{
0x0, 0x800000, 0x8000, 0x808000, 0x80, 0x562401, 0xF0EDEE, 0xC0C0C0,
0x808080, 0xFF0000, 0xFF00, 0xFFFF00, 0xFF, 0xFF00FF, 0xFFFF, 0xFFFFFF
};

// Method which contains our custom action behaviour
private static void RunSTAThread(object sessionObject)
{
try
{
Session session = sessionObject as Session;

string powerShellShortcutPath = session.CustomActionData["ShortcutPath"];
string powerShellDefaultShortcutPath = session.CustomActionData["DefaultShortcutPath"];

if (!File.Exists(powerShellShortcutPath))
{
_STAThreadException = new Exception(string.Format("UpdatePSShortcut: file {0} does not exist", powerShellShortcutPath));
return;
}

ShellLink powerShellShellLink = new ShellLink(powerShellShortcutPath);
if (File.Exists(powerShellDefaultShortcutPath))
{
session.Log("UpdatePSShortcut: found default Windows PowerShell shortcut at {0}", powerShellDefaultShortcutPath);
ShellLink powerShellDefaultShellLink = new ShellLink(powerShellDefaultShortcutPath);
powerShellShellLink.ConsoleProperties = powerShellDefaultShellLink.ConsoleProperties;
}
else
{
session.Log("UpdatePSShortcut: default Windows PowerShell shortcut does not exist at {0}", powerShellDefaultShortcutPath);

for (int i = 0; i < powerShellShellLink.ConsoleProperties.ColorTable.Length; i++)
{
powerShellShellLink.ConsoleProperties.ColorTable[i] = powerShellDefaultColorTable[i];
}
powerShellShellLink.AutoPosition = true;
powerShellShellLink.CommandHistoryBufferSize = 50;
powerShellShellLink.CommandHistoryBufferCount = 4;

powerShellShellLink.InsertMode = true;

powerShellShellLink.PopUpBackgroundColor = 15;
powerShellShellLink.PopUpTextColor = 3;

powerShellShellLink.QuickEditMode = true;

powerShellShellLink.ScreenBackgroundColor = 5;
powerShellShellLink.ScreenTextColor = 6;

powerShellShellLink.SetScreenBufferSize(120, 3000);
powerShellShellLink.SetWindowSize(120, 50);
}
powerShellShellLink.Save();
session.Log("UpdatePSShortcut: success");
}
catch (Exception ex)
{
_STAThreadException = new Exception(string.Format("UpdatePSShortcut: failed with exception {0}", ex.Message));
}
}

[CustomAction]
public static ActionResult UpdatePSShortcut(Session session)
{
Thread staThread = new Thread(RunSTAThread);
staThread.SetApartmentState(ApartmentState.STA);
staThread.Start(session);
// Wait for the new thread to finish its operations
staThread.Join();

// If there is any exception in the new thread pass it to the installer
if (_STAThreadException != null)
{
session.Log(_STAThreadException.Message);
return ActionResult.Failure;
}

return ActionResult.Success;
}
}
}
48 changes: 48 additions & 0 deletions setup-powershellget/Setup/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Setup")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Setup")]
[assembly: AssemblyCopyright("Copyright © Microsoft")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f4aa30f2-d2ce-4aef-88ed-a048b771c272")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
50 changes: 50 additions & 0 deletions setup-powershellget/Setup/Setup.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EA5BD11B-10B3-433D-A250-92AE76669D8D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.WindowsAzure.Setup</RootNamespace>
<AssemblyName>Microsoft.WindowsAzure.Setup</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<WixCATargetsPath Condition=" '$(WixCATargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.CA.targets</WixCATargetsPath>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.Deployment.WindowsInstaller" />
</ItemGroup>
<ItemGroup>
<Compile Include="CustomAction.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ShellLink.cs" />
<Content Include="CustomAction.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(WixCATargetsPath)" />
</Project>
Loading