CsprojModifier
Extension to perform additional processing when generating .csproj
com.cysharp.csprojmodifier Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/track/csprojmodifier.git?path=src/CsprojModifier/Assets/CsprojModifier README
CsprojModifier
CsprojModifier improves the developer experience in Visual Studio and Rider by performing additional processing when Unity Editor generates .csproj.
CsprojModifier provides following features:
- Insert additional projects as
Importelements into generated .csproj - Add analyzer references to generated .csproj
- Disabled if you are using Visual Studio, Rider or Visual Studio Code with Unity 2020.2 or later

Table of Contents
Works with
- Unity Editor 2022.3 (LTS) or later
- Visual Studio 2019 or Rider
Install
Add the package via git from Package Manager.
If you are using Unity 2019.1 or later, you can use Package Manager to install a package via git.
https://github.com/Cysharp/CsprojModifier.git?path=src/CsprojModifier/Assets/CsprojModifier
Features
Insert additional projects as Import elements into generated .csproj
Add references to additional project files (.props or .targets) to the generated .csproj using Import element. This enables you to add files to the project, add references, and so on.
Note: .csproj is only used in IDEs such as Visual Studio and Rider, and does not affect the actual compile time by Unity Editor.
Example
For example, you can create the following file YourAwesomeApp.DesignTime.props and import it to use BannedApiAnalyzer.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Analyzer Include="Assets/Plugins/Editor/Analyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers.dll" />
<Analyzer Include="Assets/Plugins/Editor/Analyzers/Microsoft.CodeAnalysis.CSharp.BannedApiAnalyzers.dll" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(ProjectDir)\BannedSymbols.txt" />
</ItemGroup>
</Project>
BannedApiAnalyzer expects BannedSymbols.txt as AdditionalFiles to be included in the project, so adding it this way will work.
Inject the contents of additional project files (.props, .targets) directly instead of importing them
If you specify an insert position Append Content or Prepend Content as the insertion position, CsProjModifier will read the XML file and inject the elements directly into .csproj.
<!-- * Example: `Prepend: MyApp.Unity.props` -->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--MyApp.Unity.props:HASH-->
<Import Project="MyApp.Unity.props" />
<!-- .csproj content generated by Unity Editor -->
<!-- ... -->
</Project>
<!-- * Example: `Prepend Content: MyApp.Unity.props` -->
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--MyApp.Unity.props:HASH-->
<ItemGroup>
<!-- ... -->
<!-- ... -->
<!-- ... -->
</ItemGroup>
<!-- .csproj content generated by Unity Editor -->
<!-- ... -->
</Project>
Add analyzer references to generated .csproj
NOTE: Disabled this feature if you are using Rider or Visual Studio Code with Unity 2020.2 or later. Unity Editor has Roslyn Analyzer IDE support.
Roslyn analyzers are supported in Unity 2020.2 or later. However, currently, Roslyn analyzers are not included in .csproj, and those are only used at compile time.
The extension will insert Analzyer element into .csproj when generating the project file. As a result, you can run Roslyn Analyzer when editing code in Visual Studio. (of course, you can use it before 2020.2!)
How to use
Add Roslyn Analyzer to your project in the same way that it is supported in 2020.2.
- Add the Roslyn analyzer libraries
- Uncheck all target platforms in the Plugin inspector
- Add Asset Label
RoslynAnalyzerto the libraries
License
MIT License
Installs Over Time
Operating Systems
No data yet
Top Countries
No data yet
Git Versions
No data yet
Embed Install Badge
Add an install count badge to your README
[](https://www.pkglnk.dev/pkg/csprojmodifier)<a href="https://www.pkglnk.dev/pkg/csprojmodifier"><img src="https://www.pkglnk.dev/badge/csprojmodifier.svg?style=pkglnk" alt="pkglnk installs"></a>
No comments yet. Be the first!