Skip to content

Repo sync for protected branch #10282

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 5 commits into from
Jun 18, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/clean-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/[email protected].6
- uses: actions/[email protected].7

# Call clean repo
- name: Clean repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/whats-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/checkout@b80ff79f1755d06ba70441c368a6fe801f5f3a62
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: "Print manual run reason"
if: ${{ github.event_name == 'workflow_dispatch' }}
Expand Down
34 changes: 21 additions & 13 deletions docs/ide/managing-application-settings-dotnet.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Manage application settings (.NET)
description: Manage application settings that aren't included in the application code but are needed at runtime with the Visual Studio integrated development environment (IDE).
ms.date: 03/16/2023
description: Manage application settings that aren't included in the application code but are needed at runtime with the Visual Studio IDE.
ms.date: 05/31/2024
ms.topic: conceptual
f1_keywords:
- msvse_settingsdesigner.err.nameblank
Expand All @@ -11,6 +11,7 @@ author: anandmeg
ms.author: meghaanand
manager: mijacobs
ms.subservice: general-ide
#customer intent: As a developer, I want to use application settings to store information that isn't included in the application code at runtime.
---
# Manage application settings (.NET)

Expand All @@ -19,7 +20,7 @@ Application settings enable you to store application information dynamically. Wi
> [!NOTE]
> Application settings replace the dynamic properties used in earlier versions of Visual Studio.
Each application setting must have a unique name. The name can be any combination of letters, numbers, or an underscore. However, the name can't start with a number, and it can't have spaces. The name is changed through the `Name` property.
Each application setting must have a unique name. The name can be any combination of letters, numbers, or an underscore. The name can't start with a number, and it can't have spaces. The name is changed through the `Name` property.

Application settings can be stored as any data type that is serialized to XML or has a `TypeConverter` that implements `ToString`/`FromString`. The most common types are `String`, `Integer`, and `Boolean`. You can also store values as <xref:System.Drawing.Color>, <xref:System.Object>, or as a connection string.

Expand All @@ -39,9 +40,9 @@ The project system stores application settings in two XML files:

- An *app.config* file, which is created at design time when you create the first application setting

- A *user.config* file, which is created at runtime when the user who runs the application changes the value of any user setting.
- A *user.config* file, which is created at runtime when the user who runs the application changes the value of any user setting

Notice that changes in user settings aren't written to disk unless the application specifically calls a method to do so.
Changes in user settings aren't written to disk unless the application specifically calls a method to do so.

## Create application settings at design time

Expand All @@ -51,14 +52,14 @@ At design time, you can create application settings in two ways:

- Use the **Properties** window for a form or control, which allows you to bind a setting to a property.

When you create an application-scoped setting (for example, a database connection string, or a reference to server resources), Visual Studio saves it in *app.config* file with the `<applicationSettings>` tag. (Connection strings are saved under the `<connectionStrings>` tag.)
When you create an application-scoped setting (for example, a database connection string, or a reference to server resources), Visual Studio saves it in the *app.config* file with the `<applicationSettings>` tag. Connection strings are saved under the `<connectionStrings>` tag.

When you create a user-scoped setting (for example, default font, home page, or window size), Visual Studio saves it in *app.config* file with the `<userSettings>` tag.

> [!IMPORTANT]
> When you store connection strings in *app.config*, you should take precautions to avoid revealing sensitive information, such as passwords or server paths, in the connection string.
>
> If you take connection string information from an external source, such as a user who supplies their user ID and password, you must be careful to ensure that the values you use to construct your connection string don't contain additional connection string parameters that change the behavior of your connection.
> If you take connection string information from an external source, such as a user who supplies their user ID and password, ensure that the values you use to construct your connection string don't contain additional connection string parameters that change the behavior of your connection.
>
> Consider using the Protected Configuration feature to encrypt sensitive information in the configuration file. For more information, see [Protect connection information](/dotnet/framework/data/adonet/protecting-connection-information).
Expand All @@ -71,17 +72,24 @@ You can add customized settings files to your project for convenient management

For example, you can add a *SpecialSettings.settings* file to your project. While your `SpecialSettings` class isn't exposed in the `My` namespace, **View Code** can read the custom settings file that contains `Partial Class SpecialSettings`.

The **Settings Designer** first searches for the *Settings.settings* file that the project system creates. This *Settings.settings* file is the default file that the [**Project Designer**](reference/project-properties-reference.md) displays in the **Settings** tab. The *Settings.settings* file is located in the *My Project* folder for Visual Basic projects and in the *Properties* folder for Visual C# projects. The **Project Designer** then searches for other settings files in the project's root folder. Therefore, you should put your custom settings file there. If you add a *.settings* file elsewhere in your project, the **Project Designer** won't be able to locate it.
The **Settings Designer** first searches for the *Settings.settings* file that the project system creates. This *Settings.settings* file is the default file that the [Project Designer](reference/project-properties-reference.md) displays in the **Settings** tab. The *Settings.settings* file is located in the *My Project* folder for Visual Basic projects and in the *Properties* folder for Visual C# projects. The **Project Designer** then searches for other settings files in the project's root folder. Therefore, you should put your custom settings file there. If you add a *.settings* file elsewhere in your project, the **Project Designer** can't locate it.

## Access or change application settings at runtime in Visual Basic

In Visual Basic projects, you can access application settings at runtime by using the `My.Settings` object. On the **Settings** page, select the **View code** button to view the *Settings.vb* file. *Settings.vb* defines the `Settings` class, which enables you to handle these events on the settings class: <xref:System.Configuration.ApplicationSettingsBase.SettingChanging>, <xref:System.Configuration.ApplicationSettingsBase.PropertyChanged>, <xref:System.Configuration.ApplicationSettingsBase.SettingsLoaded>, and <xref:System.Configuration.ApplicationSettingsBase.SettingsSaving>. Notice that the `Settings` class in *Settings.vb* is a partial class that displays only the user-owned code, not the whole generated class. For more information about accessing application settings by using the `My.Settings` object, see [Access application settings (.NET Framework)](/dotnet/visual-basic/developing-apps/programming/app-settings/accessing-application-settings).
In Visual Basic projects, you can access application settings at runtime by using the `My.Settings` object. On the **Settings** page, select the **View code** button to view the *Settings.vb* file. *Settings.vb* defines the `Settings` class, which enables you to handle these events on the settings class:

The values of any user-scoped settings that the user changes at runtime (for example, the position of a form) are stored in a *user.config* file. Notice that the default values are still saved in *app.config*.
- <xref:System.Configuration.ApplicationSettingsBase.SettingChanging>
- <xref:System.Configuration.ApplicationSettingsBase.PropertyChanged>
- <xref:System.Configuration.ApplicationSettingsBase.SettingsLoaded>
- <xref:System.Configuration.ApplicationSettingsBase.SettingsSaving>

If any user-scoped settings are changed during runtime, for example in testing the application, and want to reset these settings to their default values, select the **Synchronize** button.
The `Settings` class in *Settings.vb* is a partial class that displays only the user-owned code, not the whole generated class. For more information about accessing application settings by using the `My.Settings` object, see [Access application settings (.NET Framework)](/dotnet/visual-basic/developing-apps/programming/app-settings/accessing-application-settings).

It's a recommended best practice to use the `My.Settings` object and the default *.settings* file to access settings. It's recommended because you can use the **Settings Designer** to assign properties to settings, and, additionally, user settings are automatically saved before application shutdown. However, your Visual Basic application can access settings directly. In that case you have to access the `MySettings` class and use a custom *.settings* file in the root of the project. You must save the user settings before ending the application, as you would do for a C# application (as described in the following section).
The values of any user-scoped settings that the user changes at runtime, for example, the position of a form, are stored in a *user.config* file. The default values are still saved in *app.config*.

If any user-scoped settings are changed during runtime, for example in testing the application, and you want to reset these settings to their default values, select the **Synchronize** button.

We recommend that you use the `My.Settings` object and the default *.settings* file to access settings. You can use the **Settings Designer** to assign properties to settings, and, also, user settings are automatically saved before application shutdown. However, your Visual Basic application can access settings directly. In that case you have to access the `MySettings` class and use a custom *.settings* file in the root of the project. You must save the user settings before ending the application, as you would do for a C# application, as described in the following section.

<!-- markdownlint-disable MD003 MD020 -->
## Access or change application settings at runtime in C#
Expand All @@ -99,7 +107,7 @@ You must explicitly call the `Save` method of this wrapper class in order to per
Properties.Settings.Default.Save();
```

For general information about accessing application settings through the `Settings` class, see [Application settings overview (.NET Framework)](/dotnet/framework/winforms/advanced/application-settings-overview). For information about iterating through the settings, see this [forum post](https://social.msdn.microsoft.com/Forums/vstudio/40fbb470-f1e8-4a02-a4a0-9f62b54d0fc4/is-this-possible-propertiessettingsdefault?forum=csharpgeneral).
For general information about accessing application settings through the `Settings` class, see [Application settings overview (.NET Framework)](/dotnet/framework/winforms/advanced/application-settings-overview).

## Related content

Expand Down
30 changes: 21 additions & 9 deletions docs/ide/managing-project-and-solution-properties.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
---
title: Manage project and solution properties
description: Manage both the project properties and the solution properties in Visual Studio for C#, Visual Basic, F#, C++, and JavaScript projects.
ms.date: 05/26/2023
ms.date: 05/31/2024
ms.topic: conceptual
author: anandmeg
ms.author: meghaanand
manager: mijacobs
ms.subservice: general-ide
#customer intent: As a developer, I want to understand product and solution properties in Visual Studio to manage different kinds of projects.
---
# Manage project and solution properties

Projects have properties that govern many aspects of compilation, debugging, testing and deploying. Some properties are common among all project types, and some are unique to specific languages or platforms.
Projects have properties that govern many aspects of compilation, debugging, testing, and deploying. Some properties are common among all project types, and some are unique to specific languages or platforms.

You access project properties by right-clicking the [project node](use-solution-explorer.md#solution-explorer-ui) in **Solution Explorer** and selecting **Properties**, or by typing **properties** into the search box on the menu bar and selecting **Properties Window** from the results.

::: moniker range="vs-2022"

:::image type="content" source="media/vs-2022/properties-from-solution-explorer-context-menu.png" alt-text="Screenshot of the Solution Explorer context menu with the Properties option highlighted.":::

::: moniker-end

::: moniker range="vs-2019"

:::image type="content" source="media/vs-2019/properties-from-solution-explorer-context-menu.png" alt-text="Screenshot of the Solution Explorer context menu with the Properties option highlighted.":::

::: moniker-end

.NET projects might also have a properties node in the project tree itself.
Expand All @@ -35,26 +40,34 @@ Project properties are organized into groups, and each group has its own propert

### C#, Visual Basic, and F# projects

In C#, Visual Basic, and F# projects, properties are exposed in the [.NET **Project Designer**](reference/project-properties-reference.md).
In C#, Visual Basic, and F# projects, properties are exposed in the [.NET Project Designer](reference/project-properties-reference.md).

The following screenshot shows the **Build** property page in the .NET Project Designer for a console project in C#:
The following screenshot shows the **Build** property page in the .NET **Project Designer** for a console project in C#:

::: moniker range="vs-2022"

:::image type="content" source="reference/media/vs-2022/project-properties-designer-build-csharp.png" alt-text="Screenshot of the Project Designer, with the Build tab selected.":::

::: moniker-end

::: moniker range="vs-2019"

:::image type="content" source="reference/media/vs-2019/project-properties-designer-build-csharp.png" alt-text="Screenshot of the Project Designer, with the Build tab selected.":::

::: moniker-end

The following screenshot shows the **Compile** property page in the .NET Project Designer for a console project in Visual Basic:
The following screenshot shows the **Compile** property page in the .NET **Project Designer** for a console project in Visual Basic:

::: moniker range="vs-2022"

:::image type="content" source="reference/media/vs-2022/project-properties-designer-compile-visual-basic.png" alt-text="Screenshot of the Project Designer, with the Compile tab selected.":::

::: moniker-end

::: moniker range="vs-2019"

:::image type="content" source="reference/media/vs-2019/project-properties-designer-compile-visual-basic.png" alt-text="Screenshot of the Project Designer, with the Compile tab selected.":::

::: moniker-end

For more information about each of the **Project Designer** properties, see [What is the .NET Project Designer](reference/project-properties-reference.md).
Expand All @@ -64,19 +77,18 @@ For more information about each of the **Project Designer** properties, see [Wha
### C++ and JavaScript projects

C++ and JavaScript projects have a different user interface for managing project properties. The following screenshot shows a C++ project property page (JavaScript pages are similar):
C++ and JavaScript projects have a different user interface for managing project properties. The following screenshot shows a C++ project property page. JavaScript pages are similar.

:::image type="content" source="media/vs-2022/properties-page-cpp-console.png" alt-text="Screenshot of the C++ project properties page.":::

For information about C++ project properties, see [Work with project properties (C++)](/cpp/build/working-with-project-properties). For more information about JavaScript properties, see [Property pages, JavaScript](../ide/reference/property-pages-javascript.md).

## Solution properties

To access properties on the solution, right-click the [solution node](use-solution-explorer.md#solution-explorer-ui) in **Solution Explorer** and select **Properties**. In the dialog, you can set project configurations for **Debug** or **Release** builds, choose which projects should be the startup project when **F5** is pressed, and set code analysis options.
To access properties on the solution, right-click the [solution node](use-solution-explorer.md#solution-explorer-ui) in **Solution Explorer** and select **Properties**. In the dialog box, you can set project configurations for **Debug** or **Release** builds, choose which projects should be the startup project when you select **F5**, and set code analysis options.

Solution properties are stored in a Solution User Options (.suo) file. For more information about this file type, see the "[**Solution file**](solutions-and-projects-in-visual-studio.md#solution-file)" section of the [Solutions and projects in Visual Studio](solutions-and-projects-in-visual-studio.md) page.
Solution properties are stored in a Solution User Options (*.suo*) file. For more information about this file type, see [Solution file](solutions-and-projects-in-visual-studio.md#solution-file).

## Related content

- [What are solutions and projects in Visual Studio?](../ide/solutions-and-projects-in-visual-studio.md)
- [Managing solution and project properties (Visual Studio for Mac)](/visualstudio/mac/managing-solutions-and-project-properties)
Loading