Skip to content
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

dotnet sln add breaking change #43931

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions docs/core/compatibility/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
| Title | Type of change | Introduced version |
|-------------------------------------------------------------------------------|-------------------|--------------------|
| [`dotnet restore` audits transitive packages](sdk/9.0/nugetaudit-transitive-packages.md) | Behavioral change | Preview 6 |
| [`dotnet sln add` doesn't allow invalid file names](sdk/9.0/dotnet-sln.md) | Behavioral change | 9.0.2xx |
| [`dotnet watch` incompatible with Hot Reload for old frameworks](sdk/9.0/dotnet-watch.md) | Behavioral change | RC 1 |
| [`dotnet workload` commands output change](sdk/9.0/dotnet-workload-output.md) | Behavioral change | Preview 1 |
| [`installer` repo version no longer documented](sdk/9.0/productcommits-versions.md) | Behavioral change | Preview 5 |
Expand Down
47 changes: 47 additions & 0 deletions docs/core/compatibility/sdk/9.0/dotnet-sln.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: "'dotnet sln add' no longer allows invalid file names"
description: Learn about the breaking change in the .NET SDK where the CLI command 'dotnet sln add' adds support for .slnx solution files and no longer allows invalid file names.
ms.date: 12/10/2024
ai-usage: ai-assisted
ms.custom: https://github.com/dotnet/docs/issues/43882
---

# `dotnet sln add` no longer allows invalid file names

Starting in .NET SDK 9.0.2xx, the [`dotnet sln add`](../../../tools/dotnet-sln.md#add) CLI command includes support for *.slnx* solution files using the [vs-solutionpersistence](https://github.com/microsoft/vs-solutionpersistence) serializer. As a result, slight changes in behavior are expected.

## Version introduced

.NET SDK 9.0.2xx

## Previous behavior

Previously, projects and solution folders could have invalid Windows file names. They could also have invalid characters in their names. In addition, `dotnet sln add` failed if you attempted to add a nested project with the same name as an existing project.

## New behavior

Starting in .NET SDK 9.0.2xx, projects and solution folder names:

- Can't be a DOS word: `NUL`, `CON`, `AUX`, `PRN`, `COM?`, `LPT?`, or `CLOCK$` (where `?` is any number of digits).
- Must be 260 characters or less.
- Can't contain invalid characters, such as control characters or `?`, `:`, `\`, `/`, `*`, `"`, `"`, `<`, `>`, and `|`.

In addition, `dotnet sln add` now succeeds if you attempt to add a nested project with the same name as an existing project, which mimics the behavior for non-nested projects. Example: Adding `folder/project.csproj` and `parent/child/project.csproj` doesn't result in an error.

Exceptions contain the current strings, but wrap error messages from [vs-solutionpersistence](https://github.com/microsoft/vs-solutionpersistence).

## Type of breaking change

This change is a [behavioral change](../../categories.md#behavioral-change).

## Reason for change

These changes were introduced to transition to the new `vs-solutionpersistence` serializer.

## Recommended action

Review project and solution folders names to ensure they comply with the new naming restrictions.

## Affected APIs

N/A
4 changes: 4 additions & 0 deletions docs/core/compatibility/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ items:
items:
- name: "`dotnet restore` audits transitive packages"
href: sdk/9.0/nugetaudit-transitive-packages.md
- name: "`dotnet sln add` doesn't allow invalid file names"
href: sdk/9.0/dotnet-sln.md
- name: "`dotnet watch` incompatible with Hot Reload for old frameworks"
href: sdk/9.0/dotnet-watch.md
- name: "`dotnet workload` commands output change"
Expand Down Expand Up @@ -1798,6 +1800,8 @@ items:
items:
- name: "`dotnet restore` audits transitive packages"
href: sdk/9.0/nugetaudit-transitive-packages.md
- name: "`dotnet sln add` doesn't allow invalid file names"
href: sdk/9.0/dotnet-sln.md
- name: "`dotnet watch` incompatible with Hot Reload for old frameworks"
href: sdk/9.0/dotnet-watch.md
- name: "`dotnet workload` commands output change"
Expand Down
Loading