### Install Help Content Example Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/help-viewer/command-line-arguments.md This example demonstrates how to install Visual Studio help content using the 'install' operation. It specifies the catalog name, locale, and the source URI for the documentation. ```cmd hlpctntmgr.exe /operation install /catalogname VisualStudio15 /locale en-us /sourceuri d:\productDocumentation\HelpContentSetup.msha ``` -------------------------------- ### Install Visual Studio using the installer Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/install-visual-studio-versions-side-by-side.md Use this command to start a new installation of Visual Studio by using the installer that's already on the client machine. Specify a new folder path for the installation location. ```cmd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe" --installPath "C:\Program Files (x86)\Microsoft Visual Studio\" ``` -------------------------------- ### Example Offline Installation of Sign CLI Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/signing-vsix-packages.md Provides an example of how to install the Sign CLI tool from a local folder, specifying the tool name and version. ```dotnetcli dotnet tool install --global --add-source D:\NuGetTools sign --version 99.0 ``` -------------------------------- ### Build Setup Project Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/ide/reference/build-devenv-exe.md Builds a solution with a 'Setup' configuration, which is often used to generate an installer (.msi file) from a setup project. This command assumes a custom 'Setup' configuration has been created. ```shell devenv WindowsFormsApp1.sln /build Setup ``` -------------------------------- ### Example Product File for .NET Framework Installation Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/product-and-package-schema-reference.md This XML snippet demonstrates a complete product file used for installing the .NET Framework. It includes related products, package files with their associated public keys, and installation checks. ```xml ``` -------------------------------- ### Call the InstallApplication Method (C#) Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/walkthrough-creating-a-custom-installer-for-a-clickonce-application.md Instantiate your custom installer class and call the InstallApplication method, passing the path to the deployment manifest. This example shows how to initiate the installation process. ```csharp MyInstaller installer = new MyInstaller(); installer.InstallApplication(@"\\myServer\myShare\myApp.application"); MessageBox.Show("Installer object created."); ``` -------------------------------- ### Call the InstallApplication Method (VB) Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/walkthrough-creating-a-custom-installer-for-a-clickonce-application.md Instantiate your custom installer class and call the InstallApplication method, passing the path to the deployment manifest. This example shows how to initiate the installation process. ```vb Dim installer As New MyInstaller() installer.InstallApplication("\\myServer\myShare\myApp.application") MessageBox.Show("Installer object created.") ``` -------------------------------- ### Install Visual Studio using the bootstrapper Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/install-visual-studio-versions-side-by-side.md Use this command to start a new installation of Visual Studio by using the bootstrapper. Specify a new folder path for the installation location. ```cmd vs_Enterprise.exe --installPath "C:\Program Files (x86)\Microsoft Visual Studio\" ``` -------------------------------- ### Install English Visual Studio Help Content Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/help-viewer/administrator-guide.md Example command to install English content for Visual Studio to a client computer. This requires administrator rights and internet access. ```cmd C:\Program Files (x86)\Microsoft Help Viewer\v2.3\hlpctntmgr.exe /operation install /catalogname VisualStudio15 /locale en-us ``` -------------------------------- ### Define .NET Framework Redistributable Setup Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/product-and-package-schema-reference.md This XML snippet defines how to invoke the setup for the .NET Framework redistributable. It includes installation conditions and exit codes for different outcomes. ```xml ``` -------------------------------- ### Get Setup Instance by Pre-Release Status Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/launch-visual-studio-dte.md Filters and returns a specific Visual Studio setup instance based on whether it is a pre-release version. It relies on the GetSetupInstances method to enumerate available instances. ```C# private static ISetupInstance GetSetupInstance(bool isPreRelease) { return GetSetupInstances().First(i => IsPreRelease(i) == isPreRelease); } ``` -------------------------------- ### Registering a Service for an Installer Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/internals/how-to-generate-registry-information-for-an-installer.md Define service entries for an installer using the `` element. This example shows how to register a service with a specific GUID and name. ```XML ``` ```XML ``` -------------------------------- ### Example: Sign Setup.exe with SHA1 Hash Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/how-to-sign-setup-files-with-signtool-exe-clickonce.md An example of signing the Setup.exe using a provided certificate hash. Replace 'CCB...' with the actual SHA1 hash of your certificate. ```cmd signtool sign /sha1 CCB... Setup.exe ``` -------------------------------- ### Using --wait with PowerShell Process object Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/command-line-parameter-examples.md This example demonstrates an alternative method in PowerShell to use the --wait parameter with the Visual Studio bootstrapper. It manually creates and configures a Process object to start the installer and wait for its exit. ```powershell $startInfo = New-Object System.Diagnostics.ProcessStartInfo $startInfo.FileName = "vs_enterprise.exe" $startInfo.Arguments = "--all --quiet --wait" $process = New-Object System.Diagnostics.Process $process.StartInfo = $startInfo $process.Start() $process.WaitForExit() ``` -------------------------------- ### Declare Another GUID Parameter Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/ide/template-parameters.md This shows another example of declaring a template parameter for a GUID, illustrating the possibility of multiple unique GUIDs. ```text $guid5$ ``` -------------------------------- ### Sign Setup.exe using Certificate File Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/how-to-sign-setup-files-with-signtool-exe-clickonce.md Use this command to sign the Setup.exe file by providing the certificate file name. This is an alternative to using the certificate hash. ```cmd signtool sign /f CertFileName Setup.exe ``` -------------------------------- ### Display Current Installation Path URL Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/vsto/deploying-an-office-solution-by-using-clickonce.md Run `setup.exe` with the `/url` parameter without any value to display the current installation path URL. This is useful for verification. ```cmd setup.exe /url ``` -------------------------------- ### Example of IncludesProduct Element Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/relatedproducts-element-bootstrapper.md Specifies that the Microsoft Installer is included with the current product and does not require a separate installation. ```xml ``` -------------------------------- ### Get Symbol GUID Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/debugger/debug-interface-access/idiasymbol-get-guid.md Call this method to retrieve the GUID of a symbol. Ensure the DIA SDK is properly set up. The GUID is returned via the pRetVal parameter. ```C++ HRESULT get_guid ( GUID* pRetVal ); ``` -------------------------------- ### Installing All Workloads and Components Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/use-command-line-parameters-to-install-visual-studio.md Use the `--all` parameter to install all available workloads and components for a product. Alternatively, use `--allWorkloads` to install all workloads and components but exclude recommended or optional ones. ```bash --all ``` ```bash --allWorkloads ``` -------------------------------- ### Get Project Type GUIDs Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/verifying-subtypes-of-a-project-at-run-time.md Invokes GetAggregateProjectTypeGuids on the IVsAggregatableProjectCorrected interface to retrieve a string of all project type GUIDs. ```C# string projTypeGuids = AP.GetAggregateProjectTypeGuids().ToUpper(); ``` -------------------------------- ### Define Installation Commands Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/how-to-create-a-product-manifest.md This XML snippet specifies how the bootstrapper should execute the package file for installation. The '/qn' flag is automatically added for MSI files for silent installation. Arguments can be provided in the 'Arguments' attribute. ```xml ``` -------------------------------- ### Get C++ Language and Vendor GUIDs Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/debugger/reference/idebugsymbolprovider-getlanguage.md Retrieves the language and vendor GUIDs for code at a debug address using C++. ```cpp HRESULT GetLanguage( IDebugAddress* pAddress, GUID* pguidLanguage, GUID* pguidLanguageVendor ); ``` -------------------------------- ### Get C# Language and Vendor GUIDs Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/debugger/reference/idebugsymbolprovider-getlanguage.md Retrieves the language and vendor GUIDs for code at a debug address using C#. ```csharp int GetLanguage( IDebugAddress pAddress, out Guid pguidLanguage, out Guid pguidLanguageVendor ); ``` -------------------------------- ### Sign Setup.exe using Certificate Hash Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/how-to-sign-setup-files-with-signtool-exe-clickonce.md Use this command to sign the Setup.exe file with a specific certificate identified by its SHA1 hash. Ensure the certificate is installed on the development machine. ```cmd signtool sign /sha1 CertificateHash Setup.exe ``` -------------------------------- ### Generate New GUID Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/msbuild/property-functions.md Call static .NET methods to generate dynamic values. This example sets a property to a new GUID. ```xml $([System.Guid]::NewGuid()) ``` -------------------------------- ### Example Configuration File for Administrator Updates Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/applying-administrator-updates.md This JSON configuration file demonstrates how to specify command-line arguments for the installer and control reboot checks. Ensure the file content is valid JSON and uses supported options to avoid update failures. ```json "installerUpdateArgs" : ["--quiet", "--keepWindowsUpdateOn"], "checkPendingReboot" : "true" ``` -------------------------------- ### IDebugEngine2::GetEngineID Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/debugger/reference/idebugengine2-getengineid.md Gets the GUID of the debug engine (DE). ```APIDOC ## IDebugEngine2::GetEngineID ### Description Gets the GUID of the debug engine (DE). ### Syntax #### C# ```csharp int GetEngineID( out Guid pguidEngine ); ``` #### C++ ```cpp HRESULT GetEngineID( GUID* pguidEngine ); ``` ### Parameters #### Out Parameters - **pguidEngine** (Guid for C# / GUID* for C++) - The GUID of the DE. ### Return Value Returns `S_OK` if successful, otherwise returns an error code. ### Remarks Some examples of typical GUIDs are `guidScriptEng`, `guidNativeEng`, or `guidSQLEng`. New debug engines will create their own GUID for identification. ### Example ```cpp HRESULT CEngine::GetEngineId(GUID *pguidEngine) { if (pguidEngine) { // Set pguidEngine to guidBatEng, as defined in the Batdbg.idl file. // Other languages would require their own guidDifferentEngine to be //defined in the Batdbg.idl file. *pguidEngine = guidBatEng; return NOERROR; // This is typically S_OK. } else { return E_INVALIDARG; } } ``` ### See Also - [IDebugEngine2](../../../extensibility/debugger/reference/idebugengine2.md) ``` -------------------------------- ### Running Visual Studio with Setup or InstallVSTemplates Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/internals/new-project-generation-under-the-hood-part-one.md These commands are used to initialize Visual Studio and update the New Project dialog box with information from .vstemplate files. ```bash devenv /setup ``` ```bash devenv /installvstemplates ``` -------------------------------- ### Get C++ Language Information Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/debugger/reference/idebugstackframe2-getlanguageinfo.md Retrieves the name and GUID of the language for a C++ stack frame. Ensure the BSTR and GUID pointers are correctly passed. ```cpp HRESULT GetLanguageInfo ( BSTR* pbstrLanguage, GUID* pguidLanguage ); ``` -------------------------------- ### MSBuild Command Line Example for Solution Configuration Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/msbuild/errors/msb4126.md This example shows the correct syntax for specifying solution configuration and platform using MSBuild command-line arguments. Ensure correct spelling and quoting for Configuration and Platform properties. ```command-line MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU" ``` -------------------------------- ### C++ Implementation Example for EvaluateAsync Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/debugger/reference/idebugexpression2-evaluateasync.md An example implementation of the EvaluateAsync method in C++. It resets the aborted state and posts a message to start evaluation on a background thread. ```cpp HRESULT CExpression::EvaluateAsync(EVALFLAGS dwFlags, IDebugEventCallback2* pExprCallback) { // Set the aborted state to FALSE // in case the user tries to redo the evaluation after aborting. m_bAborted = FALSE; // Post the WM_EVAL_EXPR message in the message queue of the current thread. // This starts the expression evaluation on a background thread. PostThreadMessage(GetCurrentThreadId(), WM_EVAL_EXPR, 0, (LPARAM) this); return S_OK; } ``` -------------------------------- ### Example .pkgdef File Contents Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/help-viewer/behavior-overrides.md This snippet shows an example of a .pkgdef file used to configure Help Viewer settings. It demonstrates how to set various registry key values like service endpoints and online/offline help preferences. ```pkgdef [$RootKey$\Help] "NewContentAndUpdateService"="https://some.service.endpoint" "UseOnlineHelp"=dword:00000001 "OnlineBaseUrl"="https://some.service.endpoint" "OnlineHelpPreferenceDisabled"=dword:00000000 "DisableManageContent"=dword:00000000 "DisableFirstRunHelpSelection"=dword:00000001 ``` -------------------------------- ### Collapse a Range to the Start and Insert Text (Document-Level VB) Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/vsto/how-to-programmatically-collapse-ranges-or-selections-in-documents.md Collapses a range to the start of the first paragraph and inserts new text. This example is for a document-level customization. ```vb Dim range As Microsoft.Office.Interop.Word.Range = _ Me.Application.ActiveDocument.Paragraphs(1).Range range.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseStart) range.Text = "New text inserted at the beginning of the first paragraph." ``` -------------------------------- ### Example .runsettings file Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/test/configure-unit-tests-by-using-a-dot-runsettings-file.md This is a basic example of a .runsettings file. Customize the values to match your project's needs. ```xml 0 4.5.2 . est-results ``` -------------------------------- ### Collapse a Range to the Start and Insert Text (Document-Level C#) Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/vsto/how-to-programmatically-collapse-ranges-or-selections-in-documents.md Collapses a range to the start of the first paragraph and inserts new text. This example is for a document-level customization. ```csharp Microsoft.Office.Interop.Word.Range range = this.Application.ActiveDocument.Paragraphs[1].Range; range.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseStart); range.Text = "New text inserted at the beginning of the first paragraph."; ``` -------------------------------- ### Get C# Language Information Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/debugger/reference/idebugstackframe2-getlanguageinfo.md Retrieves the name and GUID of the language for a C# stack frame. Ensure the string and GUID parameters are correctly passed by reference. ```csharp int GetLanguageInfo ( ref string pbstrLanguage, ref Guid pguidLanguage ); ``` -------------------------------- ### Run a Solution using Devenv.exe Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/ide/reference/run-devenv-exe.md This example demonstrates how to compile and run a solution file using the /run switch. It specifies the full path to the solution file. ```shell devenv /run "%USERPROFILE%\source\repos\MySolution\MySolution.sln" ``` -------------------------------- ### Sample .NET "Hello World" Program Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/test/getting-started-with-unit-testing.md This is a basic C# console application example used for demonstrating unit testing setup. ```csharp namespace HelloWorld { public class Program { public static void Main() { Console.WriteLine("Hello World!"); } } } ``` -------------------------------- ### Example Visibility Constraint with Context Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/extensibility/visibilityconstraints-element.md An example of a VisibilityItem within VisibilityConstraints, specifying a command by its GUID and ID, and a context for its visibility. This is useful for controlling when specific commands are visible. ```xml ``` -------------------------------- ### Check for Existing Installation Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/how-to-create-a-product-manifest.md This XML snippet defines an MSI check to determine if the bootstrapper component is already installed. Replace the placeholder GUID with the actual product code of the redistributable. ```xml ``` -------------------------------- ### Example Command Line Execution Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/modeling/walkthrough-creating-a-custom-text-template-host.md Demonstrates how to run the custom text template host from the command line, specifying the host executable and the text template file. ```powershell CustomHost\bin\Debug\CustomHost.exe C:\TestTemplate.tt ``` -------------------------------- ### Install all Visual Studio Enterprise workloads and components Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/command-line-parameter-examples.md Use the --all parameter to initiate an interactive installation of every available workload and component for the Visual Studio Enterprise edition. ```shell vs_enterprise.exe --all ``` -------------------------------- ### Create a Layout with a Specific Workload and Recommended Components Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/create-a-network-installation-of-visual-studio.md Download a specific workload along with all its recommended components for a targeted installation. ```shell vs_enterprise.exe --layout C:\VSLayout --add Microsoft.VisualStudio.Workload.Azure --includeRecommended ``` -------------------------------- ### ProjectReference with Project Metadata and GUID Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/msbuild/errors/msb3107.md This example demonstrates a ProjectReference element that includes the 'Project' metadata with a GUID, which was previously required by older MSBuild versions to identify the referenced project. ```xml {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ``` -------------------------------- ### Deploy a specific project configuration Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/ide/reference/deploy-devenv-exe.md This example demonstrates deploying a specific project configuration within a solution. It specifies the solution file path, the solution configuration, the project to deploy, and its specific project configuration. ```shell devenv "%USERPROFILE%\source\repos\MySolution\MySolution.sln" /deploy Release /project "CSharpWinApp\CSharpWinApp.csproj" /projectconfig Release ``` -------------------------------- ### Install with install, cache, and shared paths Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/command-line-parameter-examples.md Use the --path parameter to specify custom locations for the installation, cache, and shared components. ```command-line vs_enterprise.exe --add Microsoft.VisualStudio.Workload.CoreEditor --path install="C:\VS" --path cache="C:\VS\cache" --path shared="C:\VS\shared" ``` -------------------------------- ### Create a minimal Visual Studio layout with Core Editor and English language Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/command-line-parameter-examples.md Use the --layout parameter to create a network installation. This example includes only the Visual Studio core editor and the English language pack. ```shell vs_professional.exe --layout "C:\VS" \ --lang en-US \ --add Microsoft.VisualStudio.Workload.CoreEditor ``` -------------------------------- ### Example Product Manifest XML Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/deployment/how-to-create-a-product-manifest.md This XML defines a product manifest for custom bootstrapper packages. It specifies dependencies, package files, installation checks, and commands for installing prerequisites. ```xml ``` -------------------------------- ### Install with install and cache paths Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/install/command-line-parameter-examples.md Use the --path parameter to specify custom locations for the installation and cache directories. ```command-line vs_enterprise.exe --add Microsoft.VisualStudio.Workload.CoreEditor --path install="C:\VS" --path cache="C:\VS\cache" ``` -------------------------------- ### Build Solution and Output Logs Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/ide/reference/devenv-command-line-switches.md The /out switch allows specifying a file to capture build errors. This example builds a solution and directs output to 'log.txt'. ```bash devenv mysln.sln /build Debug /out log.txt ``` -------------------------------- ### Start Remote Debugger from Command Line Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/debugger/includes/remote-debugger-configuration.md Use this command to restart the Remote Debugger from the command line. Ensure you replace `` with the actual path to your installation. ```cmd \msvsmon.exe ``` -------------------------------- ### Collapse a Range to the Start and Insert Text (VSTO Add-in VB) Source: https://github.com/microsoftdocs/visualstudio-docs/blob/main/docs/vsto/how-to-programmatically-collapse-ranges-or-selections-in-documents.md Collapses a range to the start of the first paragraph in the active document and inserts new text. This example is for a VSTO Add-in. ```vb Dim range As Microsoft.Office.Interop.Word.Range = _ Globals.ThisAddIn.Application.ActiveDocument.Paragraphs(1).Range range.Collapse(Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseStart) range.Text = "New text inserted at the beginning of the first paragraph." ```