Is there a way to use the unity-plugin with resharper-clt. I can't find any documentation or hints how to set it up. If i run inspectcode alone it finds a lot of errors because i doesn't know a thing of the unity specific stuff. Any help appreciated.
I see this issue abaddoned for long time already (
https://youtrack.jetbrains.com/issue/RSRP-436208
Looks like it's probably not gonna happen ... Could you suggest any alternatives?
Are you specifically interested in running it locally or on TeamCity?
I'd rather run something locally, changing to Teamcity is not really an option right now. I prefer rider over visual studio for unity in contrast to my colleague and I don't want to tell them about the code smells and suggestions all the time, which one gets for free with rider, so I thought the inspectcode report would come in quite handy.
Sorry to bother you again. I looked into TeamCity and find it quite nice, i does pretty much everything i wanted, my own solution to do. One little problem is still there. I only manage to get the same output of the "Inspections (.NET)" which i already got from my resharper-clt approach? How can i tell teamcity to consider the unity plugin?
We still need to fix the plugin so it can work with clt. It seems to be a considerably simple fix required, but still it will take some time. Can't give you estimate right now.
@AlbRoehm
Here is the instruction:
Let us know, how it worked for you.
If it is all good, I will investigate further about the TeamCity integration.
Thanks for your efforts, I will look into this as soon as I'm back in the office!
In my testproject everything looks good. I have to check how it works in a larger project and in ci, but as far as i can tell right now, it works as expected. Output is identical to rider inspection!
Edit: The unity related errors are fixed now, but i get a lot of errors that some names cannot be resolved: Cannot resolve symbol 'Linq' and so on.
Edit: Somehow i broke it, after deleting clt + plugin + %localappdata% and setting it up again i got it running also on a larger project
I had finally managed to do inspections on TeamCity. Here is fast and dirty approach, which worked for me. I ended up with 2 build steps:

There might be for sure multiple different approaches.
It's not the best idea to have custom package of ReSharper CLT with specific plugin.
I propose next solution (not final):
nuget.exe install -source https://nuget.org/api/v2/ JetBrains.ReSharper.CommandLineTools -version 2018.1.0 -ExcludeVersion -o targetnuget.exe install -source https://resharper-plugins.jetbrains.com/api/v2/ -source https://nuget.org/api/v2/ JetBrains.Unity -version 2018.1.0.75 -ExcludeVersion -o targetcopy .\target\JetBrains.Unity\DotFiles\**\*.* .\target\JetBrains.ReSharper.CommandLineTools\tools\%system.teamcity.build.checkoutDir%/target/JetBrains.ReSharper.CommandLineTools@van800 I tried your instructions
getting an exception below. I also noticed, it works for other plugins https://resharper-plugins.jetbrains.com/api/v2/package/PowerToys.CyclomaticComplexity/2018.1.0
Also tried to follow @derigel23 instructions, but it seems like unity plugin is not picked up
Warning: Exception while reading assembly name and mvid of as assembly in the stream.
The type "JetBrains.VsIntegration.Shell.Zones.IVisualStudioZone, JetBrains.Platform.VisualStudio.Core, Version=112.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325" is not a module zone because it does not derive from the JetBrains.Application.BuildScript.Application.Zones.IZone interface.
--- EXCEPTION #1/2 [InvalidOperationException]
Message = "The type "JetBrains.VsIntegration.Shell.Zones.IVisualStudioZone, JetBrains.Platform.VisualStudio.Core, Version=112.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325" is not a module zone because it does not derive from the JetBrains.Application.BuildScript.Application.Zones.IZone interface."
ExceptionPath = Root.InnerException
ClassName = System.InvalidOperationException
HResult = COR_E_INVALIDOPERATION=80131509
Source = JetBrains.Platform.Shell
StackTraceString = "
at JetBrains.Application.BuildScript.Application.Zones.ZonePart..ctor(PartCatalogType ctypeZoneInterface)
at JetBrains.Application.BuildScript.Application.Catalogs.PartCatalogZoneMapping.AssemblyData.ZoneMarkerGetLocallyRequiredZones(PartCatalogType part, FrugalLocalList`1 attrsMarker, ILogger logger)
"
--- Outer ---
--- EXCEPTION #2/2 [LoggerException]
Message = "The type "JetBrains.VsIntegration.Shell.Zones.IVisualStudioZone, JetBrains.Platform.VisualStudio.Core, Version=112.0.0.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325" is not a module zone because it does not derive from the JetBrains.Application.BuildScript.Application.Zones.IZone interface."
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = "Exception #1 at Root.InnerException"
HResult = COR_E_APPLICATION=80131600
StackTraceString = "
at JetBrains.Application.BuildScript.Application.Catalogs.PartCatalogZoneMapping.AssemblyData.ZoneMarkerGetLocallyRequiredZones(PartCatalogType part, FrugalLocalList`1 attrsMarker, ILogger logger)
at JetBrains.Application.BuildScript.Application.Catalogs.PartCatalogZoneMapping.AssemblyData.AddPartZones(PartCatalogType part, QualifiedNamesTrie`1 trie, ILogger logger)
at JetBrains.Application.BuildScript.Application.Catalogs.PartCatalogZoneMapping.AssemblyData.<>c.<.cctor>b__19_2(Pal pal)
at JetBrains.Util.Concurrency.LocalLazy`2.CreateValue()
at JetBrains.Util.Concurrency.LocalLazy`2.CreateValueWithMode()
at JetBrains.Application.BuildScript.Application.Catalogs.PartCatalogZoneMapping.AssemblyData.<EnumerateZones>d__8.MoveNext()
at JetBrains.Application.BuildScript.Application.Catalogs.CalculateModuleZoneTraitsForPartCatalogTables.JetBrains.Application.Table.Emit.ICalculateTraitsForPartCatalogTables.CalculateTraits(EmitTimeTables tables, OneToSetMap`2 typetraits)
at JetBrains.Application.Table.Emit.TraitsInCatalogTables.CalculateTraits(EmitTimeTables tables, ICollection`1 calculators)
at JetBrains.Application.Table.Emit.EmitCatalogTables.CreateCatalogTablesWithMetadataReader(IEnumerable`1 assemblies, IAssemblyMasterBinder masterbinder, ICollection`1 traitcalc, Stream output)
at JetBrains.Application.BuildScript.Application.Catalogs.PartCatalogs.CreateWithMetadataReaderRaw(Lifetime lifetime, IEnumerable`1 assemblies, IAssemblyMasterBinder masterbinder)
at JetBrains.Application.Environment.DeployedPackagesLoader.CreateAdHocCatalogForUncatalogedAssemblies(Lifetime lifeCreationProcess, ICollection`1 assembliesForAdHocCataloging, DeployedPackagesMasterBinderData binderlist, ICollection`1 catables)
at JetBrains.Application.Environment.DeployedPackagesLoader.Load(Lifetime lifetime, DeployedPackagesIdentity identity, Diagnostyx diag)
at JetBrains.Application.Environment.DeployedPackagesCache.LoadWithCaching(Lifetime lifetime, DeployedPackagesIdentity identity)
at JetBrains.Application.Environment.HostParameters.CollectProductPackagesInDirectoryFlatHostMixin.JetBrains.Application.Environment.HostParameters.IHaveFullPartCatalogSetHostMixin.GetFullPartCatalogSet(Lifetime lifetime)
at JetBrains.Application.Environment.HostParameters.JetHostParametersCaller.GetFullPartCatalogSet(Lifetime lifetime)
at JetBrains.Application.Environment.JetEnvironment..ctor(Lifetime lifetime, JetHostParametersCaller host)
at JetBrains.Application.Environment.JetEnvironment.<>c__DisplayClass8_0.<InternalCreate>b__0()
at JetBrains.Threading.ReentrancyGuard.Execute(String name, Action action)
at JetBrains.Application.Environment.JetEnvironment.InternalCreate(LifetimeDefinition lifetimeDefinition, JetHostParametersCaller host, JetEnvironment& environment)
at JetBrains.Application.Environment.JetEnvironment.CreateAndRun(Full hostparams)
at JetBrains.CommandLine.Common.Console.Application.CommandLineProgram.Main(Assembly assembly, Type environmentZoneType, HostInfo hostInfo, IProductInfo productInfo, String[] args)
at JetBrains.CommandLine.Common.Console.Application.CommandLineProgram.Run[TZone,TProductInfo](String productHostShortName, String[] args)
at JetBrains.CommandLine.InspectCode.InspectCodeProgram.Main(String[] args)
"
@MindWrapper Just ignore the exception. It can fire, but it should not affect the functionality.
@citizenmatt Lets fix the exception. (It doesn't affect functionality, but still)
I like the solution proposed by @derigel23 as the most flexible. Unfortunately it didn't work for me. Tried it with unity and PowerToys.CyclomaticComplexity plugins.
It only works if I put nupkg next to inspecode.exe (or to a location defined by JET_ADDITIONAL_DEPLOYED_PACKAGES)
TeamCity 2018.1 supports R# plugins specification for "ReSharper Inspections" build runner.

Note: to use "Download" command you need to ensure that https://resharper-plugins.jetbrains.com/api/v2/ was added as a nuget package source on this machine:
nuget sources Add -Name "ReSharper Plugins" -Source https://resharper-plugins.jetbrains.com/api/v2/
I found out this works without Exceptions with Re# 2018.3.2
inspectcode.exe "F:\Downloads\riderbugs\New Unity Project\New Unity Project.sln" -o="report2.xml"Hey @van800 , this works really well on my local machine, but i ran into problem when i wanted to run this in our pipeline on Gitlab. The thing is, that we would not commit our .sln or .csproj files because rider re/creates them according to the path in which you clone your repository. Not having .sln and .csproj files is the first problem. On the other hand just commiting my own .sln and .csproj files doesn't work because the paths to the linked dlls. are the absolute paths of my machine. Is there some way to generate these files like Rider does when you first open your unity project in Rider? Is there also a commandline tools which does this job for me or change the style of the files to relative paths?
Thanks for your help!
Hey! It is Unity, who is generating/regenerating solution and project. Unity has commandline interface. Try to ask in Unity community about how to do CI.
Oh ok, thanks for pointing me in the right direction. If i get this right it'll work fine! Manipulation the paths manually also got it going correctly.
It looks like there are some others people who already found out how to solve this. Thanks for pointing me there. Here's a link which will probably solve this for me
-executeMethod with reference to this method https://github.com/JetBrains/resharper-unity/blob/191/unity/EditorPlugin/UnityUtils.cs#L18 should work.
If you don't push Rider EditorPlugin to vcs, you may just copy the method itself to your codebase.
Thanks for your help.
Combining this article with your method got it all running with a nice output in ci-log in case of failure.
Most helpful comment
We still need to fix the plugin so it can work with clt. It seems to be a considerably simple fix required, but still it will take some time. Can't give you estimate right now.