0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

小ネタ: .NETプロジェクトでソースコードをサブディレクトリに整理する方法

Last updated at Posted at 2023-09-03

自分用メモ

.NETプロジェクトではソースコードはサブディレクトリに入れると勝手に追跡してくれる。

例えば以下のような構造のプロジェクトがあるとして

./
├── aaa.cs(Main関数が入っている)
├── bbb.cs
├── ccc.cs
├── project.csproj
└── project.sln

こんな感じにディレクトリを切ってわけていい

./
├── project.csproj
├── project.sln
└── src/
    ├── aaa.cs(Main関数が入っている)
    ├── bbb/
    │   └── bbb.cs
    └── ccc/
        └── ccc.cs

dotnet (build|run)時に勝手に依存関係を追いかけてくれる。dotnet run.csproj, .slnがあるディレクトリじゃないとだめ。

ソースコードやプロジェクトファイルに何か変更をする必要もない。

ファイルの再配置をvscodeでやってると、しばしばvscodeでクラスの参照できない系の警告が出るが、vscodeで [フォルダを閉じる] -> [フォルダを開く] でフォルダを開き直すと、更新後のディレクトリ構成に合わせて依存関係を追いかけ直してくれる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?