ReSharper InspectCode command line tool with Unity3D project
I have a problem with InspectCode CLI and unity project: when I run InspectCode with --no-build option result xml file contains thousands of compile errors which are not present in Rider - for every namespace it is a "Cannot resolve symbol" error. As a result, project is successfully compiled by Unity but Resharper finds lots of non-valid errors.
I tried to run inspection with --build option and it fails with error:
[MsBuild] /usr/local/share/dotnet/sdk/5.0.302/Microsoft.Common.CurrentVersion.targets (2202,5)->(2202,5) MSB4018: The "ResolveAssemblyReference" task failed unexpectedly. System.IO.IOException: The process cannot access the file '/PathToMyProject/Temp/Bin/Debug/System.Xml.dll' because it is being used by another process
I tried it several times and every time it was a different .dll file in the error message. There had not been any result.xml file when the command was finished.
Also, is it possible to set Scripting Define Symbols via CLI somehow? When Unity compiles solution it set UNITY_EDITOR define symbol, but I want to inspect code for production version of solution, where UNITY_EDITOR is not set, but specific platform defines are set instead.
Unity version: 2020.3.14f1
Rider version: 2021.1
ReSharper CommandLineTools version: 2021.3.2
Please sign in to leave a comment.
Afedulov when you invoke tool with --no-build parameter you should first build the solution by yourself.
About UNITY_EDITOR you can pass any msbuild parameters to inspectcode through --properties parameter.
Slava Barbarii Hi. Thanks for answers.
>you should first build the solution by yourself.
What the result of a built solution is supposed to be? A .dll file?
When unity builds a solution it stores everything in .apk/.ipa/.exe file.
Or have I just compiled each project in solution? In this case, opening a solution in Unity is enough and that's what I've done (and still got Cannot resolve symbol error during inspection)
I tried to build solution in rider, but got error (despite the fact the Unity compiles and runs solution successfuly):
Build was canceled. Failed to successfully launch or connect to a child MSBuild.exe process. Verify that the MSBuild.exe "/Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/MSBuild.dll" launches successfully, and that it is loading the same microsoft.build.dll that the launching process loaded. If the location seems incorrect, try specifying the correct location in the BuildParameters object, or with the MSBUILD_EXE_PATH environment variable.
Do you have mono installed in specified location? If not you need to specify your mono location as for rider (at settings) as for inspectcode (at command line parameters).
I am afraid I am not familiar with Unity build process.
You should be able to build your solution from command line through MsBuild.
If you are then all be good for inspectcode too.
It appears I had to download Resharper plugin for Unity first and put it in the root of Resharper CLT
https://plugins.jetbrains.com/plugin/11629-unity-support/versions
After that step I got list of results with correct warnings.
But in Resharper CLT in stdout I got next log error, I don't know how is sever is it.
GetProject() == null from project file
--- EXCEPTION #1/1 [LoggerException]
Message = “GetProject() == null from project file”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
at JetBrains.Util.ILoggerEx.LogMessageWithSensitiveData(ILogger this, LoggingLevel level, String message, Pair`2[] sensitiveData)
This error message repeats many times.
Hello Afedulov
Could you raise a support issue for the exceptions using the "Submit a Request" button above? Please attach logs for the run which throws the exception. You can enable logging by adding `--logfile=C:\log.txt --loglevel=Trace` options.
I am experiencing the following error in my environment as well, which led me to this forum.
Have you made any progress on this issue? Do you also need my logs?
Kyubuns yes, please. Send logs as described by Andrey Simukov
Okey, I submit a new request with loglevel=Trace log.
https://resharper-support.jetbrains.com/hc/en-us/requests/3986697