Skip to content

Commit 366d279

Browse files
Merge pull request #50137 from dotnet/main
Merge main into live
2 parents a65cfa2 + 4506620 commit 366d279

File tree

62 files changed

+1583
-1509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1583
-1509
lines changed

.github/prompts/error-consolidation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Rework the highlighted section so the focus is on how to correct each error. Thi
6868

6969
## Verify error messages
7070

71-
For every line in this table, verify that the error message associated with this error code matches the verbatim text in CSharpResources.resx. You can find the mapping using ErrorCodes.cs:
71+
For every line in this list, verify that the error message associated with this error code matches the verbatim text in CSharpResources.resx. You can find the mapping using ErrorCodes.cs:
7272

7373
1. Find that number as a constant in `ErrorCodes.cs`.
7474
2. Locate the corresponding `data` element in CSharpResources.resx. The `name` atttribute should match the number of the constant.

docs/azure/includes/dotnet-all.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@
475475
| Common | NuGet [2.2.1](https://www.nuget.org/packages/Microsoft.Azure.Common/2.2.1) | | |
476476
| Common - Dependencies | NuGet [1.0.0](https://www.nuget.org/packages/Microsoft.Azure.Common.Dependencies/1.0.0) | | |
477477
| Computer Vision | NuGet [7.0.1](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.ComputerVision/7.0.1) | | GitHub [7.0.1](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Vision.ComputerVision_6.0.0-preview.1/sdk/cognitiveservices/Vision.ComputerVision) |
478-
| Cosmos DB | NuGet [3.47.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.47.0)<br>NuGet [3.56.0-preview.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.56.0-preview.0) | [docs](/dotnet/api/overview/azure/cosmosdb) | GitHub [3.47.0](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/3.12.0/Microsoft.Azure.Cosmos) |
478+
| Cosmos DB | NuGet [3.47.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.47.0)<br>NuGet [3.57.0-preview.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.57.0-preview.0) | [docs](/dotnet/api/overview/azure/cosmosdb) | GitHub [3.47.0](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/3.12.0/Microsoft.Azure.Cosmos) |
479479
| Custom Vision Prediction | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction/2.0.0) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Vision.CustomVision.Prediction_2.0.0/sdk/cognitiveservices/Vision.CustomVision.Prediction) |
480480
| Custom Vision Training | NuGet [2.0.0](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training/2.0.0)<br>NuGet [2.1.0-preview](https://www.nuget.org/packages/Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training/2.1.0-preview) | | GitHub [2.0.0](https://github.com/Azure/azure-sdk-for-net/tree/Microsoft.Azure.CognitiveServices.Vision.CustomVision.Training_2.0.0/sdk/cognitiveservices/Vision.CustomVision.Training) |
481481
| Data Lake Analytics | NuGet [1.4.211011](https://www.nuget.org/packages/Microsoft.Azure.DataLake.USQL.SDK/1.4.211011) | | |

docs/azure/sdk/authentication/local-development-dev-accounts.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Authenticate .NET apps to Azure using developer accounts
33
description: Learn how to authenticate your application to Azure services when using the Azure SDK for .NET during local development using developer accounts.
44
ms.topic: how-to
5-
ms.date: 03/14/2025
5+
ms.date: 11/25/2025
66
ms.custom:
77
- devx-track-dotnet
88
- engagement-fy23
@@ -122,4 +122,36 @@ Connect-AzAccount -UseDeviceAuthentication
122122

123123
---
124124

125-
[!INCLUDE [Implement DefaultAzureCredential](<../includes/implement-defaultazurecredential.md>)]
125+
## Authenticate to Azure services from your app
126+
127+
The [Azure Identity library](/dotnet/api/azure.identity?view=azure-dotnet&preserve-view=true) provides implementations of <xref:Azure.Core.TokenCredential> that support various scenarios and Microsoft Entra authentication flows. The steps ahead demonstrate how to use <xref:Azure.Identity.DefaultAzureCredential> or a specific development tool credential when working with user accounts locally.
128+
129+
### Implement the code
130+
131+
Complete the following steps:
132+
133+
1. Add references to the [Azure.Identity](https://www.nuget.org/packages/Azure.Identity) and the [Microsoft.Extensions.Azure](https://www.nuget.org/packages/Microsoft.Extensions.Azure) packages in your project:
134+
135+
```dotnetcli
136+
dotnet add package Azure.Identity
137+
dotnet add package Microsoft.Extensions.Azure
138+
```
139+
140+
1. In `Program.cs`, add `using` directives for the `Azure.Identity` and `Microsoft.Extensions.Azure` namespaces.
141+
142+
1. Register the Azure service client using the corresponding `Add`-prefixed extension method.
143+
144+
Azure services are accessed using specialized client classes from the Azure SDK client libraries. Register these client types so you can access them through dependency injection across your app.
145+
146+
1. Pass a `TokenCredential` instance to the `UseCredential` method. Common `TokenCredential` examples include:
147+
148+
- A `DefaultAzureCredential` instance optimized for local development. This example sets environment variable `AZURE_TOKEN_CREDENTIALS` to `dev`. For more information, see [Exclude a credential type category](credential-chains.md#exclude-a-credential-type-category).
149+
150+
:::code language="csharp" source="../snippets/authentication/local-dev-account/Program.cs" id="snippet_DefaultAzureCredentialDev":::
151+
152+
- An instance of a credential corresponding to a specific development tool, such as `VisualStudioCredential`.
153+
154+
:::code language="csharp" source="../snippets/authentication/local-dev-account/Program.cs" id="snippet_VisualStudioCredential":::
155+
156+
> [!TIP]
157+
> When your team uses multiple development tools to authenticate with Azure, prefer a local development-optimized instance of `DefaultAzureCredential` over tool-specific credentials.

docs/azure/sdk/includes/implement-defaultazurecredential.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

docs/azure/sdk/snippets/authentication/Directory.Packages.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<PackageVersion Include="Azure.AI.OpenAI" Version="2.1.0" />
88
<PackageVersion Include="Microsoft.Extensions.AI" Version="9.3.0-preview.1.25114.11" />
99
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="9.3.0-preview.1.25114.11" />
10-
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.13.0" />
11-
<PackageVersion Include="Azure.Identity" Version="1.17.0" />
12-
<PackageVersion Include="Azure.Identity.Broker" Version="1.3.0" />
10+
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.13.1" />
11+
<PackageVersion Include="Azure.Identity" Version="1.17.1" />
12+
<PackageVersion Include="Azure.Identity.Broker" Version="1.3.1" />
1313
<PackageVersion Include="Azure.Security.KeyVault.Secrets" Version="4.8.0" />
1414
<PackageVersion Include="Azure.Storage.Blobs" Version="12.26.0" />
1515
<!-- ASP.NET Core packages -->
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>

docs/azure/sdk/snippets/authentication/local-dev-account/Program.cs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using Azure.Identity;
2-
using Microsoft.Extensions.Azure;
1+
using Microsoft.Extensions.Azure;
32
using Azure.Storage.Blobs;
4-
using Azure.Core;
3+
using Azure.Identity;
54

65
var builder = WebApplication.CreateBuilder(args);
76

8-
registerUsingServicePrincipal(builder);
7+
registerUsingUserPrincipal(builder);
98

109
var app = builder.Build();
1110

@@ -43,22 +42,30 @@
4342

4443
app.Run();
4544

46-
void registerUsingServicePrincipal(WebApplicationBuilder builder)
45+
void registerUsingUserPrincipal(WebApplicationBuilder builder)
4746
{
48-
#region snippet_DefaultAzureCredential_UseCredential
47+
#region snippet_VisualStudioCredential
4948
builder.Services.AddAzureClients(clientBuilder =>
5049
{
5150
clientBuilder.AddBlobServiceClient(
5251
new Uri("https://<account-name>.blob.core.windows.net"));
52+
53+
VisualStudioCredential credential = new();
54+
clientBuilder.UseCredential(credential);
5355
});
54-
#endregion snippet_DefaultAzureCredential_UseCredential
56+
#endregion snippet_VisualStudioCredential
5557

56-
#region snippet_DefaultAzureCredential
57-
builder.Services.AddSingleton<BlobServiceClient>(_ =>
58-
new BlobServiceClient(
59-
new Uri("https://<account-name>.blob.core.windows.net"),
60-
new DefaultAzureCredential()));
61-
#endregion snippet_DefaultAzureCredential
58+
#region snippet_DefaultAzureCredentialDev
59+
builder.Services.AddAzureClients(clientBuilder =>
60+
{
61+
clientBuilder.AddBlobServiceClient(
62+
new Uri("https://<account-name>.blob.core.windows.net"));
63+
64+
DefaultAzureCredential credential = new(
65+
DefaultAzureCredential.DefaultEnvironmentVariableName);
66+
clientBuilder.UseCredential(credential);
67+
});
68+
#endregion snippet_DefaultAzureCredentialDev
6269
}
6370

6471
internal record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
title: dotnet project convert command
3+
description: The 'dotnet project convert' command converts a file-based program to a project-based program.
4+
ms.date: 10/25/2025
5+
ai-usage: ai-assisted
6+
---
7+
# dotnet project convert
8+
9+
**This article applies to:** ✔️ .NET 10 SDK and later versions
10+
11+
## Name
12+
13+
`dotnet project convert` - Converts a file-based program to a project-based program.
14+
15+
## Synopsis
16+
17+
```dotnetcli
18+
dotnet project convert <FILE> [--dry-run] [--force] [--interactive]
19+
[-o|--output <OUTPUT_DIRECTORY>]
20+
21+
dotnet project convert -h|--help
22+
```
23+
24+
## Description
25+
26+
The `dotnet project convert` command converts a file-based program to a project-based program. This command creates a new directory named for your file, scaffolds a *.csproj* file, moves your code into a file with the same name as the input file, and translates any `#:` directives into MSBuild properties and references.
27+
28+
This makes the transition seamless, from a single file to a fully functional, buildable, and extensible project. When your file-based app grows in complexity, or you simply want the extra capabilities afforded in project-based apps, you can convert it to a standard project.
29+
30+
### Conversion process
31+
32+
The command performs the following operations:
33+
34+
1. Creates a new directory named after the input file (without extension).
35+
2. Generates a *.csproj* file with appropriate SDK and properties.
36+
3. Moves the source code to a file with the same name as the input file.
37+
4. Removes `#:` directives from the source code.
38+
5. Translates `#:sdk` directives: the first `#:sdk` directive becomes the `<Project Sdk="Sdk.Id">` or `<Project Sdk="Sdk.Id/version">` attribute, and any additional `#:sdk` directives become `<Sdk Name="Sdk.Id" />` or `<Sdk Name="Sdk.Id" Version="version" />` elements.
39+
6. Translates `#:package` directives to `<PackageReference>` elements in the project file.
40+
7. Translates `#:property` directives to MSBuild properties in the project file.
41+
8. Sets appropriate MSBuild properties based on the SDK and framework detected.
42+
43+
## Arguments
44+
45+
- `FILE`
46+
47+
The path to the file-based program to convert. The file must be a C# source file (typically with a *.cs* extension).
48+
49+
## Options
50+
51+
- **`--dry-run`**
52+
53+
Determines changes without actually modifying the file system. Shows what would be created or modified without performing the conversion.
54+
55+
- **`--force`**
56+
57+
Forces conversion even if there are malformed directives. By default, the command fails if it encounters directives that cannot be properly parsed or converted.
58+
59+
- [!INCLUDE [interactive](../../../includes/cli-interactive.md)]
60+
61+
- **`-o|--output <OUTPUT_DIRECTORY>`**
62+
63+
Specifies the output directory for the converted project. If not specified, a directory is created with the same name as the input file (without extension) in the current directory.
64+
65+
- [!INCLUDE [help](../../../includes/cli-help.md)]
66+
67+
## Examples
68+
69+
- Convert a file-based program to a project:
70+
71+
```dotnetcli
72+
dotnet project convert app.cs
73+
```
74+
75+
Given a folder containing *app.cs* with the following content:
76+
77+
```csharp
78+
#:sdk Microsoft.NET.Sdk.Web
79+
#:package Microsoft.AspNetCore.OpenApi@10.*-*
80+
81+
var builder = WebApplication.CreateBuilder();
82+
83+
builder.Services.AddOpenApi();
84+
85+
var app = builder.Build();
86+
87+
app.MapGet("/", () => "Hello, world!");
88+
app.Run();
89+
```
90+
91+
Running `dotnet project convert app.cs` results in a folder called *app* containing:
92+
93+
*app/app.cs*:
94+
95+
```csharp
96+
var builder = WebApplication.CreateBuilder();
97+
98+
builder.Services.AddOpenApi();
99+
100+
var app = builder.Build();
101+
102+
app.MapGet("/", () => "Hello, world!");
103+
app.Run();
104+
```
105+
106+
*app/app.csproj*:
107+
108+
```xml
109+
<Project Sdk="Microsoft.NET.Sdk.Web">
110+
111+
<PropertyGroup>
112+
<OutputType>Exe</OutputType>
113+
<TargetFramework>net10.0</TargetFramework>
114+
<ImplicitUsings>enable</ImplicitUsings>
115+
<Nullable>enable</Nullable>
116+
<PublishAot>true</PublishAot>
117+
<PackAsTool>true</PackAsTool>
118+
</PropertyGroup>
119+
120+
<ItemGroup>
121+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.*-*" />
122+
</ItemGroup>
123+
124+
</Project>
125+
```
126+
127+
- Convert a file-based program to a project in a specific output directory:
128+
129+
```dotnetcli
130+
dotnet project convert app.cs --output MyProject
131+
```
132+
133+
## See also
134+
135+
- [dotnet build](dotnet-build.md)
136+
- [dotnet run](dotnet-run.md)
137+
- [dotnet publish](dotnet-publish.md)
138+
- [Tutorial: Build file-based C# programs](../../csharp/fundamentals/tutorials/file-based-programs.md)

docs/core/tools/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ The following commands are installed by default:
7979
- [`package remove`](dotnet-package-remove.md)
8080
- [`package search`](dotnet-package-search.md)
8181
- [`package update`](dotnet-package-update.md)
82+
- [`project convert`](dotnet-project-convert.md) (Available since .NET 10 SDK)
8283
- [`reference add`](dotnet-reference-add.md)
8384
- [`reference list`](dotnet-reference-list.md)
8485
- [`reference remove`](dotnet-reference-remove.md)

0 commit comments

Comments
 (0)