Skip to content

Commit 66a4ef8

Browse files
authored
Remove csproj.md file (#22277)
1 parent 2e7e86c commit 66a4ef8

File tree

16 files changed

+123
-494
lines changed

16 files changed

+123
-494
lines changed

.openpublishing.redirection.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@
647647
"redirect_url": "/dotnet/core/testing/unit-testing-with-mstest",
648648
"redirect_document_id": true
649649
},
650+
{
651+
"source_path": "docs/core/tools/csproj.md",
652+
"redirect_url": "/dotnet/core/project-sdk/msbuild-props"
653+
},
650654
{
651655
"source_path": "docs/core/tools/extensibility.md",
652656
"redirect_url": "/dotnet/core/project-sdk/overview"

docs/architecture/modernize-desktop/example-migration-core.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ An interesting aspect of this tool is that it only surfaces the differences from
6060

6161
In most of the cases, you'll want to update your existing project to the new .NET Core format. However, you can also create a new project while maintaining the old one. The main drawback from updating the old project is that you lose designer support, which may be important for you. If you want to keep using the designer, you must create a new .NET Core project in parallel with the old one and share assets. If you need to modify UI elements in the designer, you can switch to the old project to do that. And since assets are linked, they'll be updated in the .NET Core project as well.
6262

63-
The [SDK-style project](../../core/project-sdk/msbuild-props.md) for .NET Core is a lot simpler than .NET Framework's project format. And apart from the previously mentioned `PackageReference` entries, you won't need to do much more. The new project format includes certain file extensions [by default](../../core/tools/csproj.md#default-compilation-includes-in-net-core-projects), such as `.cs` and `.xaml` files, without the need to explicitly include them in the project file.
63+
The [SDK-style project](../../core/project-sdk/msbuild-props.md) for .NET Core is a lot simpler than .NET Framework's project format. Apart from the previously mentioned `PackageReference` entries, you won't need to do much more. The new project format [includes files with certain extensions by default](../../core/project-sdk/overview.md#default-includes-and-excludes), such as `.cs` and `.xaml` files, without the need to explicitly include them in the project file.
6464

6565
#### Assembly.info considerations
6666

docs/core/migration/assembly-info.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: AssemblyInfo properties
3+
description: Learn about assembly attributes and how they correspond to MSBuild properties in .NET Core 2.1 and later versions.
4+
ms.topic: reference
5+
ms.date: 01/08/2021
6+
---
7+
# Map AssemblyInfo attributes to properties
8+
9+
[Assembly attributes](../../standard/assembly/set-attributes.md) that were typically present in an *AssemblyInfo* file in .NET Core 2.0 and earlier versions are automatically generated from MSBuild properties, starting in .NET Core 2.1.
10+
11+
## Properties per attribute
12+
13+
As shown in the following table, each attribute has a corresponding property that controls its content and another that disables its generation:
14+
15+
| Attribute | Property | Property to disable |
16+
|----------------------------------------------------------------|------------------------|-------------------------------------------------|
17+
| <xref:System.Reflection.AssemblyCompanyAttribute> | `Company` | `GenerateAssemblyCompanyAttribute` |
18+
| <xref:System.Reflection.AssemblyConfigurationAttribute> | `Configuration` | `GenerateAssemblyConfigurationAttribute` |
19+
| <xref:System.Reflection.AssemblyCopyrightAttribute> | `Copyright` | `GenerateAssemblyCopyrightAttribute` |
20+
| <xref:System.Reflection.AssemblyDescriptionAttribute> | `Description` | `GenerateAssemblyDescriptionAttribute` |
21+
| <xref:System.Reflection.AssemblyFileVersionAttribute> | `FileVersion` | `GenerateAssemblyFileVersionAttribute` |
22+
| <xref:System.Reflection.AssemblyInformationalVersionAttribute> | `InformationalVersion` | `GenerateAssemblyInformationalVersionAttribute` |
23+
| <xref:System.Reflection.AssemblyProductAttribute> | `Product` | `GenerateAssemblyProductAttribute` |
24+
| <xref:System.Reflection.AssemblyTitleAttribute> | `AssemblyTitle` | `GenerateAssemblyTitleAttribute` |
25+
| <xref:System.Reflection.AssemblyVersionAttribute> | `AssemblyVersion` | `GenerateAssemblyVersionAttribute` |
26+
| <xref:System.Resources.NeutralResourcesLanguageAttribute> | `NeutralLanguage` | `GenerateNeutralResourcesLanguageAttribute` |
27+
28+
Notes:
29+
30+
- `AssemblyVersion` and `FileVersion` default to the value of `$(Version)` without the suffix. For example, if `$(Version)` is `1.2.3-beta.4`, then the value would be `1.2.3`.
31+
- `InformationalVersion` defaults to the value of `$(Version)`.
32+
- If the `$(SourceRevisionId)` property is present, it's appended to `InformationalVersion`. You can disable this behavior using `IncludeSourceRevisionInInformationalVersion`.
33+
- `Copyright` and `Description` properties are also used for NuGet metadata.
34+
- `Configuration`, which defaults to `Debug`, is shared with all MSBuild targets. You can set it via the `--configuration` option of `dotnet` commands, for example, [dotnet pack](../tools/dotnet-pack.md).
35+
36+
## GenerateAssemblyInfo
37+
38+
A Boolean that enables or disables the AssemblyInfo generation. The default value is `true`.
39+
40+
## GeneratedAssemblyInfoFile
41+
42+
The relative or absolute path of the generated assembly info file. Defaults to a file named *[project-name].AssemblyInfo.[cs|vb]* in the `$(IntermediateOutputPath)` (*obj*) directory.

docs/core/migration/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The .NET Core csproj format has been changing and evolving with each new pre-rel
7272
- Remove the XML namespace (`xmlns`) from the `<Project>` element.
7373
- If it doesn't exist, add the `Sdk` attribute to the `<Project>` element and set it to `Microsoft.NET.Sdk` or `Microsoft.NET.Sdk.Web`. This attribute specifies that the project uses the SDK to be used. `Microsoft.NET.Sdk.Web` is used for web apps.
7474
- Remove the `<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />` and `<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />` statements from the top and bottom of the project. These import statements are implied by the SDK, so there is no need for them to be in the project.
75-
- If you have `Microsoft.NETCore.App` or `NETStandard.Library` `<PackageReference>` items in your project, you should remove them. These package references are [implied by the SDK](../tools/csproj.md).
75+
- If you have `Microsoft.NETCore.App` or `NETStandard.Library` `<PackageReference>` items in your project, you should remove them. These package references are [implied by the SDK](../project-sdk/overview.md).
7676
- Remove the `Microsoft.NET.Sdk` `<PackageReference>` element, if it exists. The SDK reference comes through the `Sdk` attribute on the `<Project>` element.
7777
- Remove the [globs](https://en.wikipedia.org/wiki/Glob_(programming)) that are [implied by the SDK](../project-sdk/overview.md#default-includes-and-excludes). Leaving these globs in your project will cause an error on build because compile items will be duplicated.
7878

docs/core/porting/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We recommend you use the following process when porting your project to .NET Cor
4747

4848
1. Convert your project file to the new SDK-style files structure. You can create new projects for .NET Core and copy over source files, or attempt to convert your existing project file with a tool.
4949

50-
.NET Core uses a simplified (and different) [project file format](../tools/csproj.md) than .NET Framework. You'll need to convert your project files into this format to continue. This project style allows you to also target .NET Framework, which at this point you'll still want to target.
50+
.NET Core uses a simplified (and different) [project file format](../project-sdk/overview.md) than .NET Framework. You'll need to convert your project files into this format to continue. This project style allows you to also target .NET Framework, which at this point you'll still want to target.
5151

5252
You can attempt to port smaller solutions or individual projects in one operation to the .NET Core project file format with the [dotnet try-convert](https://github.com/dotnet/try-convert) tool. `dotnet try-convert` is not guaranteed to work for all your projects, and it may cause subtle changes in behavior that you depended on. Use it as a _starting point_ that automates the basic things that can be automated. It isn't a guaranteed solution to migrating a project, as there are many differences in the targets used by the SDK style projects compared to the old-style project files.
5353

docs/core/porting/libraries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ This article describes the formal specification of .NET APIs that are intended t
2424
[Developing Libraries with Cross Platform Tools](../tutorials/libraries.md)\
2525
This article explains how to write libraries using the .NET Core CLI.
2626

27-
[Additions to the *csproj* format for .NET Core](../tools/csproj.md)\
28-
This article outlines the changes that were added to the project file as part of the move to *csproj* and MSBuild.
27+
[.NET project SDKs](../project-sdk/overview.md)\
28+
This article describes the SDK-style project file format.
2929

3030
[Porting to .NET Core - Analyzing your Third-Party Party Dependencies](third-party-deps.md)\
3131
This article discusses the portability of third-party dependencies and what to do when a NuGet package dependency doesn't run on .NET Core.

docs/core/project-sdk/msbuild-props.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ The `TieredCompilationQuickJitForLoops` property configures whether the JIT comp
500500

501501
### AssetTargetFallback
502502

503-
The `AssetTargetFallback` property lets you specify additional compatible framework versions for project references and NuGet packages. For example, if you specify a package dependency using `PackageReference` but that package doesn't contain assets that are compatible with your projects's `TargetFramework`, the `AssetTargetFallback` property comes into play. The compatibility of the referenced package is rechecked using each target framework that's specified in `AssetTargetFallback`.
503+
The `AssetTargetFallback` property lets you specify additional compatible framework versions for project references and NuGet packages. For example, if you specify a package dependency using `PackageReference` but that package doesn't contain assets that are compatible with your projects's `TargetFramework`, the `AssetTargetFallback` property comes into play. The compatibility of the referenced package is rechecked using each target framework that's specified in `AssetTargetFallback`. This property replaces the deprecated property `PackageTargetFallback`.
504504

505505
You can set the `AssetTargetFallback` property to one or more [target framework versions](../../standard/frameworks.md#supported-target-frameworks).
506506

@@ -526,7 +526,7 @@ Set this property to `true` to disable implicit `FrameworkReference` or [Package
526526

527527
The `PackageReference` item defines a reference to a NuGet package.
528528

529-
The `Include` attribute specifies the package ID. The `Version` attribute specifies the version or version range. For information about how to specify a minimum version, maximum version, range, or exact match, see [Version ranges](/nuget/concepts/package-versioning#version-ranges). You can also add the following metadata to a project reference: `IncludeAssets`, `ExcludeAssets`, and `PrivateAssets`.
529+
The `Include` attribute specifies the package ID. The `Version` attribute specifies the version or version range. For information about how to specify a minimum version, maximum version, range, or exact match, see [Version ranges](/nuget/concepts/package-versioning#version-ranges). You can also add [asset attributes](#asset-attributes) to a package reference.
530530

531531
The project file snippet in the following example references the [System.Runtime](https://www.nuget.org/packages/System.Runtime/) package.
532532

@@ -538,6 +538,31 @@ The project file snippet in the following example references the [System.Runtime
538538

539539
For more information, see [Package references in project files](/nuget/consume-packages/package-references-in-project-files).
540540

541+
#### Asset attributes
542+
543+
The `IncludeAssets`, `ExcludeAssets`, and `PrivateAssets` metadata can be added to a package reference.
544+
545+
| Attribute | Description |
546+
| - | - |
547+
| `IncludeAssets` | Specifies which assets belonging to the package specified by `<PackageReference>` should be consumed. By default, all package assets are included. |
548+
| `ExcludeAssets`| Specifies which assets belonging to the package specified by `<PackageReference>` should not be consumed. |
549+
| `PrivateAssets` | Specifies which assets belonging to the package specified by `<PackageReference>` should be consumed but not flow to the next project. The `Analyzers`, `Build`, and `ContentFiles` assets are private by default when this attribute is not present. |
550+
551+
These attributes can contain one or more of the following items, separated by a semicolon `;` if more than
552+
one is listed:
553+
554+
- `Compile` – the contents of the *lib* folder are available to compile against.
555+
- `Runtime` – the contents of the *runtime* folder are distributed.
556+
- `ContentFiles` – the contents of the *contentfiles* folder are used.
557+
- `Build` – the props/targets in the *build* folder are used.
558+
- `Native` – the contents from native assets are copied to the *output* folder for runtime.
559+
- `Analyzers` – the analyzers are used.
560+
561+
Alternatively, the attribute can contain:
562+
563+
- `None` – none of the assets are used.
564+
- `All` – all assets are used.
565+
541566
### ProjectReference
542567

543568
The `ProjectReference` item defines a reference to another project. The referenced project is added as a NuGet package dependency, that is, it's treated the same as a `PackageReference`.

docs/core/project-sdk/overview.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ If the project has multiple target frameworks, focus the results of the command
7777

7878
`dotnet msbuild -property:TargetFramework=netcoreapp2.0 -preprocess:output.xml`
7979

80-
### Default includes and excludes
80+
## Default includes and excludes
8181

8282
The default includes and excludes for [`Compile` items](/visualstudio/msbuild/common-msbuild-project-items#compile), [embedded resources](/visualstudio/msbuild/common-msbuild-project-items#embeddedresource), and [`None` items](/visualstudio/msbuild/common-msbuild-project-items#none) are defined in the SDK. Unlike non-SDK .NET Framework projects, you don't need to specify these items in your project file, because the defaults cover most common use cases. This behavior makes the project file smaller and easier to understand and edit by hand, if needed.
8383

@@ -92,7 +92,7 @@ The following table shows which elements and which [globs](https://en.wikipedia.
9292
> [!NOTE]
9393
> The `./bin` and `./obj` folders, which are represented by the `$(BaseOutputPath)` and `$(BaseIntermediateOutputPath)` MSBuild properties, are excluded from the globs by default. Excludes are represented by the [DefaultItemExcludes property](msbuild-props.md#defaultitemexcludes).
9494
95-
#### Build errors
95+
### Build errors
9696

9797
If you explicitly define any of these items in your project file, you're likely to get a "NETSDK1022" build error similar to the following:
9898

@@ -126,6 +126,31 @@ To resolve the errors, do one of the following:
126126

127127
If you only disable `Compile` globs, Solution Explorer in Visual Studio still shows \*.cs items as part of the project, included as `None` items. To disable the implicit `None` glob, set `EnableDefaultNoneItems` to `false` too.
128128

129+
## Build events
130+
131+
In SDK-style projects, use an MSBuild target named `PreBuild` or `PostBuild` and set the `BeforeTargets` property for `PreBuild` or the `AfterTargets` property for `PostBuild`.
132+
133+
```xml
134+
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
135+
<Exec Command="&quot;$(ProjectDir)PreBuildEvent.bat&quot; &quot;$(ProjectDir)..\&quot; &quot;$(ProjectDir)&quot; &quot;$(TargetDir)&quot;" />
136+
</Target>
137+
138+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
139+
<Exec Command="echo Output written to $(TargetDir)" />
140+
</Target>
141+
```
142+
143+
> [!NOTE]
144+
>
145+
> - You can use any name for the MSBuild targets. However, the Visual Studio IDE recognizes `PreBuild` and `PostBuild` targets, so by using those names, you can edit the commands in the IDE.
146+
> - The properties `PreBuildEvent` and `PostBuildEvent` are not recommended in SDK-style projects, because macros such as `$(ProjectDir)` aren't resolved. For example, the following code is not supported:
147+
>
148+
> ```xml
149+
> <PropertyGroup>
150+
> <PreBuildEvent>"$(ProjectDir)PreBuildEvent.bat" "$(ProjectDir)..\" "$(ProjectDir)" "$(TargetDir)"</PreBuildEvent>
151+
> </PropertyGroup>
152+
> ```
153+
129154
## Customize the build
130155
131156
There are various ways to [customize a build](/visualstudio/msbuild/customize-your-build). You may want to override a property by passing it as an argument to an [msbuild](/visualstudio/msbuild/msbuild-command-line-reference) or [dotnet](../tools/index.md) command. You can also add the property to the project file or to a *Directory.Build.props* file. For a list of useful properties for .NET projects, see [MSBuild reference for .NET SDK projects](msbuild-props.md).
@@ -162,7 +187,7 @@ The following XML is a snippet from a *.csproj* file that instructs the [`dotnet
162187
</ItemGroup>
163188
</Target>
164189
...
165-
190+
166191
</Project>
167192
```
168193

0 commit comments

Comments
 (0)