How to add bunch of external tools into Visual Studio IDE using Powershell command? - powershell

I'm able to add third party tools by manually using External Tools - which is available in the Visual Studio IDE. But my requirement is, need to add more tools by executing powershell script. Is this possible?

Yes, you could use StudioShell to work with Visual Studio's DTE object. See here and here for some examples.

You could also do this using an exported xml file, or just create on in your powershell script like what is done here
Basic jist of it:
param($installPath, $toolsPath, $package, $project)
# Determine fully qualified path to a temp file
$fileName = [System.IO.Path]::GetTempPath() + [System.Guid]::NewGuid().ToString() + ".vssettings";
# Create User Settings file:
'<UserSettings>
<ApplicationIdentity version="9.0"/>
<ToolsOptions/>
<Category name="Environment_Group" RegisteredName="Environment_Group">
<Category name="Environment_ExternalTools" Category="{E8FAE9E8-FBA2-4474-B134-AB0FFCFB291D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_ExternalTools" PackageName="Visual Studio Environment Package">
<PropertyValue name="Launch Powershell.Command">powershell.exe</PropertyValue>
<PropertyValue name="Launch Powershell.Arguments">"& ''$(ProjectDir)\Myscript.ps1''"</PropertyValue>
<PropertyValue name="Launch Powershell.InitialDirectory">"$(ProjectDir)"</PropertyValue>
<PropertyValue name="Launch Powershell.SourceKeyName"/>
<PropertyValue name="Launch Powershell.UseOutputWindow">true</PropertyValue>
<PropertyValue name="Launch Powershell.PromptForArguments">false</PropertyValue>
<PropertyValue name="Launch Powershell.CloseOnExit">true</PropertyValue>
<PropertyValue name="Launch Powershell.IsGUIapp">false</PropertyValue>
<PropertyValue name="Launch Powershell.SaveAllDocs">true</PropertyValue>
<PropertyValue name="Launch Powershell.UseTaskList">false</PropertyValue>
<PropertyValue name="Launch Powershell.Unicode">false</PropertyValue>
<PropertyValue name="Launch Powershell.Package">{00000000-0000-0000-0000-000000000000}</PropertyValue>
<PropertyValue name="Launch Powershell.NameID">0</PropertyValue>
<PropertyValue name="ToolNames">Launch Powershell</PropertyValue>
</Category>
</Category>
</UserSettings>' >> $fileName
# Perform the import of the custom tool
$project.DTE.ExecuteCommand("Tools.ImportandExportSettings", "/import:""$fileName""");
"--Remove file"
Remove-Item -path $fileName
NOTE: In order to utilize the Visual Studio DTE, you need to use a third party extension such as PSCX (PowerShell Community Extension)

Related

smartfield annotation - valuehelp dropdown - does not show description

I have a problem where the smartfield (build in xml view using WebIDE) does not show the description of the key field instead just shows the key field in both the dropdown list columns.
example : 1(1) and the expectation is 1( local tax ) .
My service is built using tcode : SEGW and using WebIDE to develop the ui and annotation for the dropdown as a fixed list.
I see a solution smartfield annotation - valuehelp dropdown , but I am unable to add the sap:text to my service in SEGW.
Problem :
Issue Screenshot
Annotation in WebIDE:
</Annotations>
<Annotations Target="Metadata.ET_FV60Header/Pmethod">
<Annotation Term="Common.Text" String="Text1"/>
<Annotation Term="Common.ValueListWithFixedValues" Bool="true"/>
<Annotation Term="Common.ValueList">
<Record>
<PropertyValue Property="CollectionPath" String="VH_PmtMethSet"/>
<PropertyValue Property="Parameters">
<Collection>
<Record Type="Common.ValueListParameterInOut">
<PropertyValue Property="LocalDataProperty" PropertyPath="Pmethod"/>
<PropertyValue Property="ValueListProperty" String="Zlsch"/>
<Annotation Term="Common.Label" String="Text1"/>
</Record>
<Record Type="Common.ValueListParameterDisplayOnly">
<PropertyValue Property="ValueListProperty" String="Text1"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
I was able to solve the problem by adding the property "sap:text" to my entity definition in SAP using the following;
Open the corresponding ZCL*MPC_EXT class using tcode SE80 or SE24.
Redefine the method "DEFINE" under the above class. Additional properties can be added here in this method for services created via tcode : SEGW.
Code to be added under DEFINE method
** ET_Entity is my Value Help Entity data model name ( not entity set)
** FIELD_ID is the key property under the above entity to which we want to display the description in the dropdown list.
** FIELD_DESC is the property that contains the description.
Entity metadata :
Entity Data definition for Value Help( as Drop Down list )
You could do the same by adding a further annotation (targeting a specific property of the "helper" entity set) directly in WebIDE as follows:
<Annotations Target="Metadata.VH_PmtMeth/Zlsch">
<Annotation Term="Common.Text" Path="Text1"/>
</Annotations>

Controlling the sequence of events in a Wixtoolset (.msi) installer

I am creating a Microsoft Installer (.msi file) using the Wixtoolset (Windows Installer XML). This installer must automate the installation of an existing .exe program (named installer.exe below) and copy a custom configuration file (named settings.conf below) to the target directory. In addition the installer must modify the configuration file using the InstallFiles command below. But the timing of events is critical. If the executable installer runs too early, it fails or exhibits strange behavior. And if the executable installer run too late in the install sequence, it overwrites my modified configuration file with the generic values. I believe this can be done by assigning a string to the Before or After property value. What Before or After property assignment will allow the executable to run properly but not overwrite the configuration file I moved by the CopyFile element? Here is my Wixtoolset XML code.
<Property Id="CONFIGFOLDER" Value="C:\acme\config" >
<Feature
Id="ConfigurationFile"
Title="Configuration File"
Level="1"
<ComponentRef Id="CMP_ACME_Config_File" />
</Feature>
<DirectoryRef Id="TARGETDIR">
<Component Id="CMP_ACME_Config_File" Guid="">
<File
Id="ACME_Config"
Source="MySettings.conf"
KeyPath="yes"
<CopyFile Id="Copy_ACME_Config"
DestinationProperty="CONFIGFOLDER"
DestinationName="settings.conf" />
</File>
</Component>
</DirectoryRef>
<Binary
Id="InstallerEXE"
SourceFile="installer.exe" />
<CustomAction
Id="Launch_Installer"
BinaryKey="InstallerEXE"
Impersonate="yes"
Execute="deferred"
ExeCommand=""
Return="check" />
<InstallExecuteSequence>
<Custom Action="Launch_Installer"
Before="InstallFiles">
</Custom>
</InstallExecuteSequence>
</Property>
I can't explain exactly why this works but assigning "InstallFiles" to the "After" property in the "Custom" element seems to do the trick.
<InstallExecuteSequence>
<Custom Action="Launch_Installer"
After="InstallFiles">
</Custom>
</InstallExecuteSequence>

How to to overwrite Properties of search fields of Smart Filter Bar using local annotation file

I’m trying to overwrite smart filter bar search fields properties such as “Label”, “Required” using local annotations file
Annotation file - annotation related to ArtcleNumber field
<Annotations xmlns="http://docs.oasis-open.org/odata/ns/edm"
Target="XXX/ArticleNumber">
<Annotation Term="Common.ValueList">
<Record>
<PropertyValue Property="Label" String="Article"/>
<PropertyValue Property="CollectionPath"
String="ArticleFilterSet"/>
<PropertyValue Property="SearchSupported"
Bool="true"/>
<PropertyValue Property="Parameters">
<Collection>
<Record Type="Common.ValueListParameterOut">
<PropertyValue Property="LocalDataProperty"
PropertyPath="ArticleNumber"/>
<PropertyValue Property="ValueListProperty"
String="Article"/>
</Record>
<Record Type="Common.ValueListParameterDisplayOnly">
<PropertyValue Property="ValueListProperty" String="Article"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
But Label is not getting overwrite from annotation file. Still It is taken from back end service metadata file
Please Help me on this. thanks

WIX - Reference a heat generated file ID for use in Custom Action

New to Wix, but trying to learn!
I'm using heat to generate a 'directory.wxs' file that contains all of the files I need for my application. One of these files is a Powershell script that I need to run as a custom action. I'm trying to use the -suid flag so the File Id is consistent across runs. I don't like this solution as I may be in a bad way if I ever have two files with the same name... suggestions welcome on that one.
In the customaction.wxs file, I'm trying to use what is generated, "install-service-filebeat.ps1" as my Property value in my custom action. I have looked at a quite a few examples / problems similar to this across here and other sites. I may just be an idiot and missing something, but was wondering if my issue is with referencing the ID from my directory.wxs file, or if it elsewhere in my syntax.
Below are my scripts, I included them at the end as they are long.
Thanks in advance!
My PS script:
## Powershell Script to Create MSI ##
## Variables ##
# WIX Source Dir #
$WIX_DIR="C:\Program Files (x86)\WiX Toolset v3.11\bin"
# Source Dir for files to be enumerated into MSI #
$SRC_DIR="C:\application-directory"
# Name of our Application #
$APP_NAME="Filebeat"
# Where to stage the various .wxs files #
$STG_DIR="C:\wix-project\${APP_NAME}\stage"
# Where to deliver the Final Product #
$TGT_DIR="C:\wix-project\${APP_NAME}\output"
## Create MSI ##
# Compile the source files into a Fragment to be referenced by main builder Product.wxs #
& ${WIX_DIR}\heat.exe dir $SRC_DIR -srd -dr INSTALLDIR -cg MainComponentGroup -out ${STG_DIR}\directory.wxs -ke -sfrag -gg -ssuid -var var.SourceDir -sreg -scom
# Convert the .wxs files into .wxobj for consumption by light.exe #
& ${WIX_DIR}\candle.exe -dSourceDir="${SRC_DIR}" ${STG_DIR}\*.wxs -o ${STG_DIR}\ -ext WixUtilExtension -arch x64
# Create the final MSI package --CURRENTLY REFERENCING THE FILES EXPLICITY. NEED TO FIND WAY TO WILDCARD! #
& ${WIX_DIR}\light.exe -o ${TGT_DIR}\${APP_NAME}_installer.msi ${STG_DIR}\customaction.wixobj ${STG_DIR}\directory.wixobj ${STG_DIR}\product.wixobj -cultures:en-US -ext WixUIExtension.dll -ext WiXUtilExtension.dll
This generates my files just fine, and compiles them. The contents of my customaction.wxs:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<!--Define the CustomAction for running the PowerShell script-->
<CustomAction Id="RunPowerShellScript_set"
Property="install_service.ps1"
Value=""[\[]POWERSHELLEXE[\]]" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "&'4(var.SourceDir)\[\[]#install_service.ps1[\]]'; exit $$($Error.Count)"" />
<CustomAction Id="RunPowerShellScript"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="deferred"
Return="check"
Impersonate="yes" />
<!-- Ensure PowerShell is installed and obtain the PowerShell executable location -->
<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<Condition Message="This application requires Windows PowerShell.">
<![CDATA[Installed OR POWERSHELLEXE]]>
</Condition>
</Fragment>
</Wix>
And the relevant portion of my product.wxs:
<!-- Execute Custom Action -->
<InstallExecuteSequence>
<Custom Action="RunPowerShellScript_set" After="InstallFiles" />
<Custom Action="RunPowerShellScript" After="InstallFiles">
<![CDATA[NOT Installed]]>
</Custom>
</InstallExecuteSequence>
I think that your Property="install_service.ps1" is incorrect. Try to follow the pattern from my blog post. I hope it helps you, just tested my script again and it works. Have a nice day!

WiX Bootstrapper: How do I set burn variables from the command line?

Using WiX 3.7 and .NET 4.0.
How does one set burn variables when running a WiX bootstrapper EXE from the command line?
First of all, the burn variables that you wish to set need to be set as Overridable. To do this you must include the follow namespace in your WXS: xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" and if you're using Visual Studio like me you need to include WixBalExtension.dll in your project references. Next you need to add the following attribute to all of the burn variables that you want to set via the command line: bal:Overridable="yes".
Now you can set the variables via the command line in this fashion:
BootstrapperSetup.exe /i /passive MyBurnVariable1=1 MyBurnVariable2=2
Below is an example of a WXS file that satifies all of the conditions described above:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="MyProduct" Version="1.0.0" Manufacturer="MyManufacturer" UpgradeCode="PUT-UPGRADE-CODE-HERE">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense">
<bal:WixStandardBootstrapperApplication LicenseUrl="MyLicense.htm" ThemeFile="MyThemeFile.xml" LocalizationFile="MyLocFile.wxl" />
</BootstrapperApplicationRef>
<Variable Name="MyBurnVariable1" bal:Overridable="yes" Type="numeric" Value="0" />
<Variable Name="MyBurnVariable2" bal:Overridable="yes" Type="numeric" Value="0" />
<Chain>
<MsiPackage Id="MyFirstMsiPackage"
SourceFile="first.msi"
InstallCondition="MyBurnVariable1 = 1" />
<MsiPackage Id="MySecondMsiPackage"
SourceFile="second.msi">
<MsiProperty Name="MY_PROPERTY" Value="[MyBurnVariable2]" />
</MsiPackage>
</Chain>
</Bundle>
</Wix>