Skip to content

Repo sync for protected CLA branch #8691

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

Merged
merged 16 commits into from
Nov 24, 2022
Merged
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
87 changes: 87 additions & 0 deletions docs/deployment/access-clickonce-deployment-properties-dotnet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
title: Access ClickOnce deployment properties for .NET
description: "Learn how to access ClickOnce deployment properties for .NET Core 3.1, .NET 5 and later."
ms.date: 11/21/2022
ms.topic: how-to
helpviewer_keywords:
- "deployment properties, ClickOnce for .NET 5+"
author: mikejo5000
ms.author: mikejo
manager: jmartens
ms.technology: vs-ide-deployment
monikerRange: '>= vs-2022'
ms.workload:
- "multiple"
---
# Access ClickOnce deployment properties for .NET on Windows

[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]

Starting in .NET 7 and Visual Studio 2022 version 17.4, you can access ClickOnce deployment properties using an environment variable.

The application launcher shares ClickOnce application deployment properties with the application being launched (.NET only). Properties are shared with the application using environment variables.

The variable names closely match the properties in the .NET Framework <xref:System.Deployment.Application.ApplicationDeployment> class. The new variable names include a ClickOnce_ prefix:

- [ClickOnce_IsNetworkDeployed](/dotnet/api/system.deployment.application.applicationdeployment.isnetworkdeployed)
- [ClickOnce_ActivationUri](/dotnet/api/system.deployment.application.applicationdeployment.activationuri)
- [ClickOnce_CurrentVersion](/dotnet/api/system.deployment.application.applicationdeployment.currentversion)
- [ClickOnce_DataDirectory](/dotnet/api/system.deployment.application.applicationdeployment.datadirectory)
- [ClickOnce_IsFirstRun](/dotnet/api/system.deployment.application.applicationdeployment.isfirstrun)
- [ClickOnce_TimeOfLastUpdateCheck](/dotnet/api/system.deployment.application.applicationdeployment.timeoflastupdatecheck)
- [ClickOnce_UpdatedApplicationFullName](/dotnet/api/system.deployment.application.applicationdeployment.updatedapplicationfullname)
- [ClickOnce_UpdatedVersion](/dotnet/api/system.deployment.application.applicationdeployment.updatedversion)
- [ClickOnce_UpdateLocation](/dotnet/api/system.deployment.application.applicationdeployment.updatelocation)

In addition to these, a new property is available that returns the application launcher version:

- ClickOnce_LauncherVersion

A .NET application can use these properties directly or indirectly.

## Access properties

The following code example shows how to access two properties directly, `ClickOnce_IsNetworkDeployed` and `ClickOnce_ActivationUri`.

```csharp
NameValueCollection nameValueTable = new NameValueCollection();
if (Environment.GetEnvironmentVariable("ClickOnce_IsNetworkDeployed")?.ToLower() == "true")
{
string value = Environment.GetEnvironmentVariable("ClickOnce_ActivationUri");
Uri activationUri = string.IsNullOrEmpty(value) ? null : new Uri(value);
if (activationUri != null)
{
nameValueTable = HttpUtility.ParseQueryString(activationUri.Query);
Console.WriteLine("Query string: " + activationUri.Query);
Console.ReadKey();
}
}
```

Indirect usage of these properties requires the implementation of a new ApplicationDeployment class, at the application level, that abstracts the reading of environment variables and provides an experience that is very similar to old .NET Framework class.

For a sample implementation of this class, see [ApplicationDeployment.cs](https://github.com/dotnet/deployment-tools/blob/main/Documentation/dotnet-mage/ApplicationDeployment.cs).

With the addition of this class, you can use it as follows:

```csharp
NameValueCollection nameValueTable = new NameValueCollection();
if (ApplicationDeployment.IsNetworkDeployed)
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
if (ad.ActivationUri != null)
{
nameValueTable = HttpUtility.ParseQueryString(ad.ActivationUri.Query);
}
}
```

## ActivationUri and URL parameters

In .NET 7, dotnet-mage supports a new switch, `-TrustURLParameters` or `-tu`. This switch allows you to set the required deployment attribute using the dotnet-mage tool. This is an improvement over old Mage tool, which did not support this functionality and instead required you to manually modify the application manifest to add the `trustURLParameters` attribute, as follows: \<deployment install="true" trustURLParameters="true"\>

You need to set trustURLParameters to true to allow the application to access ActivationUri and the URL parameters.

## See also

[ClickOnce for .NET on Windows](../deployment/clickonce-deployment-dotnet.md)
8 changes: 6 additions & 2 deletions docs/deployment/clickonce-deployment-dotnet.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: ClickOnce for .NET 5 and later on Windows
description: "Learn about differences between ClickOnce for .NET Core 3.1, .NET 5 and later versus ClickOnce for .NET Framework."
ms.date: 09/14/2022
ms.date: 11/22/2022
ms.topic: how-to
helpviewer_keywords:
- "deployment, ClickOnce for .NET 5+"
Expand Down Expand Up @@ -29,7 +29,11 @@ For building from the command line using MSBUILD, you need to specify the *.pubx

## ApplicationDeployment class

In .NET Core 3.1 and .NET 5 and later, you don't have programmatic access to the <xref:System.Deployment.Application.ApplicationDeployment> class or to other APIs in the <xref:System.Deployment.Application> namespace.
In .NET Core 3.1, .NET 5, and .NET 6, you don't have programmatic access to the <xref:System.Deployment.Application.ApplicationDeployment> class or to other APIs in the <xref:System.Deployment.Application> namespace.

::: moniker range=">=vs-2022"
Starting in .NET 7, you can access properties in the `ApplicationDeployment` class using environment variables. For more information, see [Access ClickOnce deployment properties in .NET](../deployment/access-clickonce-deployment-properties-dotnet.md).
::: moniker-end

## Mage.exe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ title: Visual Studio .NET ClickOnce API support
author: mikejo5000
description: Learn about .NET ClickOnce API support in ClickOnce
ms.author: mikejo
ms.date: 09/12/2022
ms.date: 11/22/2022
ms.technology: vs-ide-deployment
ms.topic: include
---

> [!NOTE]
> The <xref:System.Deployment.Application.ApplicationDeployment> class and APIs in the <xref:System.Deployment.Application> namespace are not supported in .NET Core or .NET 5 and later.
> The <xref:System.Deployment.Application.ApplicationDeployment> class and APIs in the <xref:System.Deployment.Application> namespace are not supported in .NET Core and .NET 5 and later versions. However, .NET 7 supports a new method of accessing application deployment properties. For more information, see [Access ClickOnce deployment properties in .NET](../../deployment/access-clickonce-deployment-properties-dotnet.md).
10 changes: 7 additions & 3 deletions docs/deployment/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@
items:
- name: Deploy to Azure using GitHub Actions
href: azure-deployment-using-github-actions.md
- name: ClickOnce security and deployment
- name: ClickOnce
items:
- name: Overview of ClickOnce security and deployment
href: clickonce-security-and-deployment.md
- name: ClickOnce for .NET on Windows
href: clickonce-deployment-dotnet.md
- name: ClickOnce for .NET
items:
- name: ClickOnce for .NET on Windows
href: clickonce-deployment-dotnet.md
- name: Access ClickOnce deployment properties for .NET
href: access-clickonce-deployment-properties-dotnet.md
- name: Choose a ClickOnce deployment strategy
href: choosing-a-clickonce-deployment-strategy.md
- name: ClickOnce cache overview
Expand Down
45 changes: 32 additions & 13 deletions docs/ide/user-permissions-and-visual-studio.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Run as administrator
description: Learn how to run Visual Studio as an administrator.
ms.date: 10/26/2021
ms.date: 11/23/2022
ms.topic: conceptual
helpviewer_keywords:
- Visual Studio, user permissions
Expand Down Expand Up @@ -31,44 +31,63 @@ You can do nearly everything in the Visual Studio IDE as a typical user. You nee
|Installation|Install or modify Visual Studio.|[Install Visual Studio](../install/install-visual-studio.md), [Modify Visual Studio](../install/modify-visual-studio.md)|
||Install, update, or remove local Help content.|[Install and manage local Help content](../help-viewer/install-manage-local-content.md)|
|Toolbox|Add classic COM controls to **Toolbox**.|[Toolbox](../ide/reference/toolbox.md)|
|Building|Use post-build events that register a component.|[Understand custom build steps and build events](/cpp/build/understanding-custom-build-steps-and-build-events)|
||Include a registration step when you build C++ projects.||
|Building|Use post-build events that register a component, or include a registration step when you build C++ projects. |[Understand custom build steps and build events](/cpp/build/understanding-custom-build-steps-and-build-events)|
|Debugging|Debug applications that run with elevated permissions.|[Debugger settings and preparation](../debugger/debugger-settings-and-preparation.md)|
||Debug applications that a run under a different user account, such as ASP.NET websites.|[Debug ASP.NET and AJAX applications](../debugger/how-to-enable-debugging-for-aspnet-applications.md)|
||Debug in Zone for XAML Browser Applications (XBAP).|[WPF host (PresentationHost.exe)](/dotnet/framework/wpf/app-development/wpf-host-presentationhost-exe)|
||Use the emulator to debug cloud service projects for Microsoft Azure.|[Debug a cloud service in Visual Studio](/azure/vs-azure-tools-debug-cloud-services-virtual-machines)|
||Configure a firewall for remote debugging.|[Remote debugging](../debugger/remote-debugging.md)|
|Performance tools|Attaching to an elevated application.|[Beginners guide to performance profiling](../profiling/beginners-guide-to-performance-profiling.md)|
|Performance tools|Attaching to an elevated application.|[Measure application performance](../profiling/beginners-guide-to-performance-profiling.md)|
||Use the GPU Profiler.|[GPU profiling](../profiling/gpu-usage.md)|
|Deployment|Deploy a web application to Internet Information Services (IIS) on a local computer.|[Deploy an ASP.NET web app using Visual Studio](/aspnet/web-forms/overview/older-versions-getting-started/deployment-to-a-hosting-provider/)|
|Deployment|Deploy a web application to Internet Information Services (IIS) on a local computer.|[ASP.NET web deployment using Visual Studio](/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/introduction)|
|Development|Developing SharePoint Solutions.|[Create SharePoint solutions](../sharepoint/create-sharepoint-solutions.md)|

## Run Visual Studio as an administrator

If you need to run Visual Studio as an administrator, follow these steps to open the IDE:
If you need to run Visual Studio as an administrator, here's how.

> [!NOTE]
> These instructions are for Windows 10. They are similar for other versions of Windows.
### Use the Start menu

1. Open the **Start** menu, and scroll to Visual Studio.
1. Depending on the version of Windows you're using, perform one of the following steps:

1. From the right-click or context menu of **Visual Studio 2019** or **Visual Studio 2022**, select **More** > **Run as administrator**.
- In **Windows 10**, open the **Start** menu, and then scroll to Visual Studio.
- In **Windows 11**, select the Start button, and then in the **Search** box, type **Visual Studio**.

1. Next, right-click either **Visual Studio 2019** or **Visual Studio 2022**, and then select **More** > **Run as administrator**.

When Visual Studio starts, **(Administrator)** appears after the product name in the title bar.

You can also modify the application shortcut to always run with administrative permissions:
### Modify the shortcut

You can also modify the application shortcut to always run with administrative permissions. Here's how.

#### Windows 10

1. Open the **Start** menu, scroll to the version of Visual Studio that you're using, and then select **More** > **Open file location**.

1. In **File Explorer**, locate the **Visual Studio** shortcut for the version that you're using. Then, right-click the shortcut and select **Send to** > **Desktop (create shortcut)**.

1. On the **Windows** desktop, right-click the **Visual Studio** shortcut, and then select **Properties**.
1. On the **Windows 10** desktop, right-click the **Visual Studio** shortcut, and then select **Properties**.

1. Select the **Advanced** button, and then select the **Run as administrator** check box.

1. Select **OK**, and then select **OK** again.

#### Windows 11

1. Select the **Start** button, and then in the **Search** box, enter **Visual Studio**.

1. From the search results, right-click either **Visual Studio 2019** or **Visual Studio 2022**, and then select **Open file location**.

1. In **File Explorer**, locate the **Visual Studio** shortcut for the version that you're using. Then, right-click the shortcut and select **Show more options** > **Send to** > **Desktop (create shortcut)**.

1. On the **Windows 11** desktop, right-click the **Visual Studio** shortcut, and then select **Properties**.

1. Next, select the **Advanced** button, and then select the **Run as administrator** check box.

1. Select **OK** two times to close the dialog.

## See also

- [Port, migrate, and upgrade Visual Studio projects](../porting/port-migrate-and-upgrade-visual-studio-projects.md)
- [Install Visual Studio](../install/install-visual-studio.md)
- [Port, migrate, and upgrade Visual Studio projects](../porting/port-migrate-and-upgrade-visual-studio-projects.md)
2 changes: 1 addition & 1 deletion docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,7 @@
items:
- name: Develop secure applications
href: ide/securing-applications.md
- name: Run Visual Studio as normal user or administrator
- name: Run Visual Studio as an administrator
href: ide/user-permissions-and-visual-studio.md
- name: Windows Information Protection (WIP)
href: ide/exempt-visual-studio-from-wip.md
Expand Down
5 changes: 4 additions & 1 deletion docs/version-control/git-create-branch.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Create a branch
description: Create a branch for source control in Visual Studio with Git.
ms.date: 10/20/2022
ms.date: 11/23/2022
ms.topic: how-to
author: TerryGLee
ms.author: tglee
Expand Down Expand Up @@ -40,6 +40,9 @@ There you have it; you've created a new branch.
> [!TIP]
> The equivalent command for this action is `git checkout -b <new-branch> <existing-branch>`.

> [!NOTE]
> For more information about the latest updates that improve branch switching, see the [Visual Studio 2022 Performance Enhancements: Git Branch Switching](https://devblogs.microsoft.com/visualstudio/vs2022-performance-enhancements-git-branch-switching/) blog post.

## Next steps

To continue your journey, visit the [Make a commit](git-make-commit.md) page. And to learn more about how to manage branches in Visual Studio, see [Merge and rebase branches](git-manage-repository.md#merge-and-rebase-branches).