Manage .NET (C#) solutions, projects, and files
As Fleet supports a lot of different languages and technologies, it does not have a universal concept of a project, instead it operates with workspaces, where a workspace is a directory that contains everything associated with your current development task.
On the other hand, C# code is normally organized in projects and solutions, with corresponding configuration files (.csproj and .sln). If you have .csproj or .sln files in your workspace, JetBrains Fleet will help you open the corresponding projects and solutions in the dedicated view.
Work with solutions in a dedicated view
In most cases when you work with C# code, you need to see code items organized in projects and solutions, which is the way you see code structure in traditional .NET IDEs like Visual Studio and JetBrains Rider.
JetBrains Fleet also lets you work with the solution structure — as soon as you enable Smart Mode in a workspace that contains a .NET solution, JetBrains Fleet opens the Solution tool.
If the workspace contains a single .sln file, the solution opens automatically, otherwise you can choose what solution to open.
Manage .NET projects and solutions
To bridge the gap between workspace and project or solution in Fleet, you need to use the directory where the .csproj or .sln file resides as a workspace.
In the current version, Fleet has a user interface for creating projects, but it doesn't have the UI for creating solutions. However, you can always use the .NET command-line interface (CLI) for creating both projects and solutions. .NET CLI is included in the .NET SDK, which you should have installed as described in prerequisites.
Create a new project and solution
Press ⌘ O or select File | Open from the menu.
In the file browser, navigate to an empty folder where you want to store your code and click Open.
This will open the desired folder as a workspace in the Files view.
Select Terminal view.
from the main menu or press ⌃ ⇧ ` to open theMake sure that the command line is in the root of the workspace, and create a new project from a dotnet project template. For example, we can create a new console application
MyConsoleApp
. To do so, type the following in the terminal:dotnet new console -o MyConsoleAppThis command will create a new MyConsoleApp directory and place the project configuration file MyConsoleApp.csproj and an initial source file Program.cs in this directory.
Use the dotnet sln command to create a new solution for your project. Let's call it
FleetTestSolution
. Type the following in the terminal:dotnet new sln --name FleetTestSolutionTo add the project to the solution, type
dotnet sln add MyConsoleAppNow you can switch to the Files view to create and open project files from there.
Open an existing project or solution
Press ⌘ O or select File | Open from the menu.
Select the directory that contains the .csproj file of the target project or the .sln file of the target solution, and click Open.
When you first create or open a project or solution in JetBrains Fleet, you will see its file system structure in the Files view and have basic editor features as well as textual search.
When you enable Smart Mode, JetBrains Fleet will analyze and index everything included in the solution, and you will be able to see the solution structure in the Solution view and access tons of code intelligence features.
If there are several .sln files in the directory or that you open, JetBrains Fleet will help you choose the solution you want to work with — after clicking the Smart Mode Status icon on the toolbar, click the link in the popup and select the desired solution.
If you open a directory that contains one or more solutions in its subdirectories, the .NET-specific features and the Solution view will not be activated until you open a .NET-specific file (for example, .cs or .csproj).
Manage projects and files in your solution
Add a new project from the Solution tool
Select Solution tool.
from the menu to open theRight-click the solution node and choose New Project....
In the dialog that opens, specify a name for the new project and choose one of the project templates in the Type selector. Optionally, specify a custom project directory.
Click Add to create the project and close the dialog.
Add a new project via command line
Select Terminal view.
from the main menu or press ⌃ ⇧ ` to open theMake sure that the command line is in the root of the workspace, where the solution's .sln file resides.
Use dotnet project templates to create a project of the desired type.
For example, to create a class library
TestLib
, type the following:dotnet new classlib -o TestLibTo add the new project to the solution, use the
dotnet sln add
command, for example:dotnet sln add TestLib
Add C# files
Do one of the following:
To create a new file in a specific project or folder, select this project or folder in the Solution or Files view and press ⌘ N or right-click and select New File.... Then type a filename with the .cs extension and press ⏎.
To create a new file next to the file currently opened in the editor, make sure that the focus is in the editor and press ⌘ N or select .cs extension and press ⏎.
from the menu. Then type a filename with the
Press ← and → to choose the desired template for the new file and then press ⏎ to select it.
Add references to other projects within the solution
Use a type from a non-referenced project in your code. For example, if that project declares the class
ArchiveFolder
, you can typevar archiveFolder = new ArchiveFolder();Place the caret to the name of the class, press ⌥ ⏎, and choose Reference project...:
This will add a new project reference and the corresponding
using
directive.
Install NuGet packages
Select Terminal view.
from the main menu or press ⌃ ⇧ ` to open theIn the command line, switch to the directory that contains the .csproj file of the target project.
Type the following command:
dotnet add package <package.name>For example, to install the
JetBrains.Annotations
package, v. 2022.1.0 type the following command:dotnet add package JetBrains.Annotations --version 2022.1.0For more information about dotnet CLI, refer to the Microsoft Docs.