This project has been moved to GitHub.
For the latest documentation please follow this link:
https://github.com/realvizu/NsDepCop
2. "Setup is unable to add NsDepCop target to the C# build workflow..."
3. "Setup is unable to remove NsDepCop target from the C# build workflow..."
4. Anonymous types raise false alarms
5. Where can I download the .NET Compiler Platform (Roslyn) End User Preview (for Visual Studio 2013)?
6. How to suppress/enable NsDepCop info messages in the MSBuild output?
1. How to choose which parser is used by NsDepCop MSBuild task?
2. "Setup is unable to add NsDepCop target to the C# build workflow..."
In order to insert the NsDepCop task into the C# project build workflow, setup creates (or modifies) the "Custom.After.Microsoft.CSharp.targets" file at "(Program Files folder)\MsBuild\v4.0". It redefines the "BuildDependsOn" property group to include the NsDepCop target as the last step just before the "Build" target executes. If you already have this file and it already contains the definition of the BuildDependsOn property group then setup won't change it (so not to mess up anything).
In this case you have to insert the NsDepCop target manually. Append a semicolon and the string "NsDepCop" at the end of the text inside the "BuildDependsOn" tags. Like this:
Before:
After:
3. "Setup is unable to remove NsDepCop target from the C# build workflow..."
The same problem as above when uninstalling NsDepCop. The "Custom.After.Microsoft.CSharp.targets" file at "(Program Files folder)\MsBuild\v4.0" contains a definition of the BuildDependsOn property group that is different from the content that setup creates. You have to remove the NsDepCop string from the BuildDependsOn definition manually.
4. Anonymous types raise false alarms
For anonymous types the compiler generates a class with no namespace so they will belong to the 'global namespace'. If your NsDepCop config does not allow referencing the global namespace (denoted with a single dot) then it will raise a (false) alarm.
To allow the usage of anonymous types you have to add a rule that you allow referencing the global namespace:
Or to be more lax:
5. Where can I download the .NET Compiler Platform (Roslyn) End User Preview (for Visual Studio 2013)?
Unfortunately .NET Compiler Platform (Roslyn) End User Preview (for Visual Studio 2013) is not available from Microsoft to download any more.
You can find it in the source tree: VS2013\prereq\Roslyn End User Preview.vsix
6. How to suppress/enable NsDepCop info messages in the MSBuild output?
NsDepCop error and warning messages are always displayed in the MSBuild output.
However some NsDepCop messages are only informal (eg. analysis started, finished) and these can be suppressed or enabled.
In MSBuild you can set what kind of information messages you want to see.
MsBuild verbosity and NsDepCop InfoImportance together determine which messages will show up in the output and which will be suppressed. See MSDN for the exact relation between LoggerVerbosity and MessageImportance values.
For the latest documentation please follow this link:
https://github.com/realvizu/NsDepCop
FAQ
1. How to choose which parser is used by NsDepCop MSBuild task?2. "Setup is unable to add NsDepCop target to the C# build workflow..."
3. "Setup is unable to remove NsDepCop target from the C# build workflow..."
4. Anonymous types raise false alarms
5. Where can I download the .NET Compiler Platform (Roslyn) End User Preview (for Visual Studio 2013)?
6. How to suppress/enable NsDepCop info messages in the MSBuild output?
1. How to choose which parser is used by NsDepCop MSBuild task?
- Open the Custom.After.Microsoft.CSharp.targets file.
- Find it at: C:\Program Files (x86)\MSBuild\v14.0
- Locate the NsDepCopTask tag.
- Add/modify the attribute named Parser.
- Supported values are: NRefactory, Roslyn
- Roslyn is the default if the Parser attribute is missing or have unrecognized value.
- Eg.
<NsDepCopTaskReferencePath="@(ReferencePath)"Compile="@(Compile)"BaseDirectory="$(MSBuildProjectDirectory)"Parser="Roslyn"/>
2. "Setup is unable to add NsDepCop target to the C# build workflow..."
In order to insert the NsDepCop task into the C# project build workflow, setup creates (or modifies) the "Custom.After.Microsoft.CSharp.targets" file at "(Program Files folder)\MsBuild\v4.0". It redefines the "BuildDependsOn" property group to include the NsDepCop target as the last step just before the "Build" target executes. If you already have this file and it already contains the definition of the BuildDependsOn property group then setup won't change it (so not to mess up anything).
In this case you have to insert the NsDepCop target manually. Append a semicolon and the string "NsDepCop" at the end of the text inside the "BuildDependsOn" tags. Like this:
Before:
<PropertyGroup><BuildDependsOn> $(BuildDependsOn); MyCustomTask </BuildDependsOn></PropertyGroup>"
<PropertyGroup><BuildDependsOn> $(BuildDependsOn); MyCustomTask; NsDepCop </BuildDependsOn></PropertyGroup>
3. "Setup is unable to remove NsDepCop target from the C# build workflow..."
The same problem as above when uninstalling NsDepCop. The "Custom.After.Microsoft.CSharp.targets" file at "(Program Files folder)\MsBuild\v4.0" contains a definition of the BuildDependsOn property group that is different from the content that setup creates. You have to remove the NsDepCop string from the BuildDependsOn definition manually.
4. Anonymous types raise false alarms
For anonymous types the compiler generates a class with no namespace so they will belong to the 'global namespace'. If your NsDepCop config does not allow referencing the global namespace (denoted with a single dot) then it will raise a (false) alarm.
To allow the usage of anonymous types you have to add a rule that you allow referencing the global namespace:
<AllowedFrom="YourNamespace"To="."/>
Or to be more lax:
<AllowedFrom="*"To="."/>
5. Where can I download the .NET Compiler Platform (Roslyn) End User Preview (for Visual Studio 2013)?
Unfortunately .NET Compiler Platform (Roslyn) End User Preview (for Visual Studio 2013) is not available from Microsoft to download any more.
You can find it in the source tree: VS2013\prereq\Roslyn End User Preview.vsix
6. How to suppress/enable NsDepCop info messages in the MSBuild output?
NsDepCop error and warning messages are always displayed in the MSBuild output.
However some NsDepCop messages are only informal (eg. analysis started, finished) and these can be suppressed or enabled.
In MSBuild you can set what kind of information messages you want to see.
- In command line: use the /verbosity switch.
- In Visual Studio use: Tools/Options/Projects and Solutions/Build and Run/MSBuild project build output verbosity
- Open the Custom.After.Microsoft.CSharp.targets file.
- Find it at: C:\Program Files (x86)\MSBuild\v14.0
- Locate the NsDepCopTask tag.
- Add/modify the attribute named InfoImportance.
- Supported values are: High, Normal, Low
- The default if Normal.
- Eg.
<NsDepCopTaskReferencePath="@(ReferencePath)"Compile="@(Compile)"BaseDirectory="$(MSBuildProjectDirectory)"InfoImportance="Low"/>
MsBuild verbosity and NsDepCop InfoImportance together determine which messages will show up in the output and which will be suppressed. See MSDN for the exact relation between LoggerVerbosity and MessageImportance values.