Skip to content

Commit 287b186

Browse files
committed
Merging changes synced from https://github.com/MicrosoftDocs/visualstudio-docs-pr (branch live)
2 parents 46e551e + ab6a449 commit 287b186

File tree

7 files changed

+139
-22
lines changed

7 files changed

+139
-22
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: Access ClickOnce deployment properties for .NET
3+
description: "Learn how to access ClickOnce deployment properties for .NET Core 3.1, .NET 5 and later."
4+
ms.date: 11/21/2022
5+
ms.topic: how-to
6+
helpviewer_keywords:
7+
- "deployment properties, ClickOnce for .NET 5+"
8+
author: mikejo5000
9+
ms.author: mikejo
10+
manager: jmartens
11+
ms.technology: vs-ide-deployment
12+
monikerRange: '>= vs-2022'
13+
ms.workload:
14+
- "multiple"
15+
---
16+
# Access ClickOnce deployment properties for .NET on Windows
17+
18+
[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]
19+
20+
Starting in .NET 7 and Visual Studio 2022 version 17.4, you can access ClickOnce deployment properties using an environment variable.
21+
22+
The application launcher shares ClickOnce application deployment properties with the application being launched (.NET only). Properties are shared with the application using environment variables.
23+
24+
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:
25+
26+
- [ClickOnce_IsNetworkDeployed](/dotnet/api/system.deployment.application.applicationdeployment.isnetworkdeployed)
27+
- [ClickOnce_ActivationUri](/dotnet/api/system.deployment.application.applicationdeployment.activationuri)
28+
- [ClickOnce_CurrentVersion](/dotnet/api/system.deployment.application.applicationdeployment.currentversion)
29+
- [ClickOnce_DataDirectory](/dotnet/api/system.deployment.application.applicationdeployment.datadirectory)
30+
- [ClickOnce_IsFirstRun](/dotnet/api/system.deployment.application.applicationdeployment.isfirstrun)
31+
- [ClickOnce_TimeOfLastUpdateCheck](/dotnet/api/system.deployment.application.applicationdeployment.timeoflastupdatecheck)
32+
- [ClickOnce_UpdatedApplicationFullName](/dotnet/api/system.deployment.application.applicationdeployment.updatedapplicationfullname)
33+
- [ClickOnce_UpdatedVersion](/dotnet/api/system.deployment.application.applicationdeployment.updatedversion)
34+
- [ClickOnce_UpdateLocation](/dotnet/api/system.deployment.application.applicationdeployment.updatelocation)
35+
36+
In addition to these, a new property is available that returns the application launcher version:
37+
38+
- ClickOnce_LauncherVersion
39+
40+
A .NET application can use these properties directly or indirectly.
41+
42+
## Access properties
43+
44+
The following code example shows how to access two properties directly, `ClickOnce_IsNetworkDeployed` and `ClickOnce_ActivationUri`.
45+
46+
```csharp
47+
NameValueCollection nameValueTable = new NameValueCollection();
48+
if (Environment.GetEnvironmentVariable("ClickOnce_IsNetworkDeployed")?.ToLower() == "true")
49+
{
50+
string value = Environment.GetEnvironmentVariable("ClickOnce_ActivationUri");
51+
Uri activationUri = string.IsNullOrEmpty(value) ? null : new Uri(value);
52+
if (activationUri != null)
53+
{
54+
nameValueTable = HttpUtility.ParseQueryString(activationUri.Query);
55+
Console.WriteLine("Query string: " + activationUri.Query);
56+
Console.ReadKey();
57+
}
58+
}
59+
```
60+
61+
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.
62+
63+
For a sample implementation of this class, see [ApplicationDeployment.cs](https://github.com/dotnet/deployment-tools/blob/main/Documentation/dotnet-mage/ApplicationDeployment.cs).
64+
65+
With the addition of this class, you can use it as follows:
66+
67+
```csharp
68+
NameValueCollection nameValueTable = new NameValueCollection();
69+
if (ApplicationDeployment.IsNetworkDeployed)
70+
{
71+
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
72+
if (ad.ActivationUri != null)
73+
{
74+
nameValueTable = HttpUtility.ParseQueryString(ad.ActivationUri.Query);
75+
}
76+
}
77+
```
78+
79+
## ActivationUri and URL parameters
80+
81+
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"\>
82+
83+
You need to set trustURLParameters to true to allow the application to access ActivationUri and the URL parameters.
84+
85+
## See also
86+
87+
[ClickOnce for .NET on Windows](../deployment/clickonce-deployment-dotnet.md)

docs/deployment/clickonce-deployment-dotnet.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: ClickOnce for .NET 5 and later on Windows
33
description: "Learn about differences between ClickOnce for .NET Core 3.1, .NET 5 and later versus ClickOnce for .NET Framework."
4-
ms.date: 09/14/2022
4+
ms.date: 11/22/2022
55
ms.topic: how-to
66
helpviewer_keywords:
77
- "deployment, ClickOnce for .NET 5+"
@@ -29,7 +29,11 @@ For building from the command line using MSBUILD, you need to specify the *.pubx
2929

3030
## ApplicationDeployment class
3131

32-
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.
32+
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.
33+
34+
::: moniker range=">=vs-2022"
35+
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).
36+
::: moniker-end
3337

3438
## Mage.exe
3539

docs/deployment/includes/dotnet-support-application-deployment-api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ title: Visual Studio .NET ClickOnce API support
33
author: mikejo5000
44
description: Learn about .NET ClickOnce API support in ClickOnce
55
ms.author: mikejo
6-
ms.date: 09/12/2022
6+
ms.date: 11/22/2022
77
ms.technology: vs-ide-deployment
88
ms.topic: include
99
---
1010

1111
> [!NOTE]
12-
> 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.
12+
> 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).

docs/deployment/toc.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@
5555
items:
5656
- name: Deploy to Azure using GitHub Actions
5757
href: azure-deployment-using-github-actions.md
58-
- name: ClickOnce security and deployment
58+
- name: ClickOnce
5959
items:
6060
- name: Overview of ClickOnce security and deployment
6161
href: clickonce-security-and-deployment.md
62-
- name: ClickOnce for .NET on Windows
63-
href: clickonce-deployment-dotnet.md
62+
- name: ClickOnce for .NET
63+
items:
64+
- name: ClickOnce for .NET on Windows
65+
href: clickonce-deployment-dotnet.md
66+
- name: Access ClickOnce deployment properties for .NET
67+
href: access-clickonce-deployment-properties-dotnet.md
6468
- name: Choose a ClickOnce deployment strategy
6569
href: choosing-a-clickonce-deployment-strategy.md
6670
- name: ClickOnce cache overview

docs/ide/user-permissions-and-visual-studio.md

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Run as administrator
33
description: Learn how to run Visual Studio as an administrator.
4-
ms.date: 10/26/2021
4+
ms.date: 11/23/2022
55
ms.topic: conceptual
66
helpviewer_keywords:
77
- Visual Studio, user permissions
@@ -31,44 +31,63 @@ You can do nearly everything in the Visual Studio IDE as a typical user. You nee
3131
|Installation|Install or modify Visual Studio.|[Install Visual Studio](../install/install-visual-studio.md), [Modify Visual Studio](../install/modify-visual-studio.md)|
3232
||Install, update, or remove local Help content.|[Install and manage local Help content](../help-viewer/install-manage-local-content.md)|
3333
|Toolbox|Add classic COM controls to **Toolbox**.|[Toolbox](../ide/reference/toolbox.md)|
34-
|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)|
35-
||Include a registration step when you build C++ projects.||
34+
|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)|
3635
|Debugging|Debug applications that run with elevated permissions.|[Debugger settings and preparation](../debugger/debugger-settings-and-preparation.md)|
3736
||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)|
3837
||Debug in Zone for XAML Browser Applications (XBAP).|[WPF host (PresentationHost.exe)](/dotnet/framework/wpf/app-development/wpf-host-presentationhost-exe)|
3938
||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)|
4039
||Configure a firewall for remote debugging.|[Remote debugging](../debugger/remote-debugging.md)|
41-
|Performance tools|Attaching to an elevated application.|[Beginners guide to performance profiling](../profiling/beginners-guide-to-performance-profiling.md)|
40+
|Performance tools|Attaching to an elevated application.|[Measure application performance](../profiling/beginners-guide-to-performance-profiling.md)|
4241
||Use the GPU Profiler.|[GPU profiling](../profiling/gpu-usage.md)|
43-
|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/)|
42+
|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)|
4443
|Development|Developing SharePoint Solutions.|[Create SharePoint solutions](../sharepoint/create-sharepoint-solutions.md)|
4544

4645
## Run Visual Studio as an administrator
4746

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

50-
> [!NOTE]
51-
> These instructions are for Windows 10. They are similar for other versions of Windows.
49+
### Use the Start menu
5250

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

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

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

59-
You can also modify the application shortcut to always run with administrative permissions:
60+
### Modify the shortcut
61+
62+
You can also modify the application shortcut to always run with administrative permissions. Here's how.
63+
64+
#### Windows 10
6065

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

6368
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)**.
6469

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

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

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

76+
#### Windows 11
77+
78+
1. Select the **Start** button, and then in the **Search** box, enter **Visual Studio**.
79+
80+
1. From the search results, right-click either **Visual Studio 2019** or **Visual Studio 2022**, and then select **Open file location**.
81+
82+
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)**.
83+
84+
1. On the **Windows 11** desktop, right-click the **Visual Studio** shortcut, and then select **Properties**.
85+
86+
1. Next, select the **Advanced** button, and then select the **Run as administrator** check box.
87+
88+
1. Select **OK** two times to close the dialog.
89+
7190
## See also
7291

73-
- [Port, migrate, and upgrade Visual Studio projects](../porting/port-migrate-and-upgrade-visual-studio-projects.md)
7492
- [Install Visual Studio](../install/install-visual-studio.md)
93+
- [Port, migrate, and upgrade Visual Studio projects](../porting/port-migrate-and-upgrade-visual-studio-projects.md)

docs/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@
12691269
items:
12701270
- name: Develop secure applications
12711271
href: ide/securing-applications.md
1272-
- name: Run Visual Studio as normal user or administrator
1272+
- name: Run Visual Studio as an administrator
12731273
href: ide/user-permissions-and-visual-studio.md
12741274
- name: Windows Information Protection (WIP)
12751275
href: ide/exempt-visual-studio-from-wip.md

docs/version-control/git-create-branch.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Create a branch
33
description: Create a branch for source control in Visual Studio with Git.
4-
ms.date: 10/20/2022
4+
ms.date: 11/23/2022
55
ms.topic: how-to
66
author: TerryGLee
77
ms.author: tglee
@@ -40,6 +40,9 @@ There you have it; you've created a new branch.
4040
> [!TIP]
4141
> The equivalent command for this action is `git checkout -b <new-branch> <existing-branch>`.
4242
43+
> [!NOTE]
44+
> 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.
45+
4346
## Next steps
4447

4548
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).

0 commit comments

Comments
 (0)