I'm trying to configure my project from within the Unity Editor to treat all warning messages as errors, but I can't seem to find any documentation pertaining to this. Is there a way that I can configure this for my project? Thank you so much!
Create a text file in ProjectFolder/Assets/smcs.rsp
Everything in that file will end up as compiler command-line parameters
The parameter to force warnings as errors is -warnaserror+, so add this to the smcs.rsp
If you are interested in other available parameters, run UnityInstallFolder/editor/data/bin/smcs /?
More on https://answers.unity.com/questions/216838/how-to-force-warnings-as-errors.html
Related
Rebuilding the project does not run Reinforced typings. It says in Output:
warning : Reinforced.Typings will not run because it is disabled in its configuration
I tried making a completely clean and new project, but the same thing happened.
It does not seem to be an error in the xml or Configuration files to me.
How do you enable it?
Usually RT is being disabled by <RtDisable> parameter set to true (actually any value that differs from 'false'). Please double-check it.
Also please check that there is reference to Reinforced.Typings.targets from your .csproj file (it must be added automatically by NuGet).
I have a project which is developed with Unity3D. Now I want to add StyleCop to this project.
I have added this awesome package which shows the warnings already in VisualStudio (this is a great benefit over StyleCop Classic). But now I want to see the warnings in Unity and let the build fail. To let the build fail if there are any warnings, I have already added a csc.rsp file with -warnaserror+, but unfortunately, I don't have any warnings in Unity.
Is it possible to get the StyleCop-warnings to the Unity-Editor?
Unity-Version 2019.3.0b7 if that matters.
Edit: Another view of the same issue would be:
How to install an analyzer to roslyn?
Unfortunately I the options to install a roslyn analyzer seem to be to install it as nuget package or as Visual Studio extension. But since both ways integrate the errors into Visual Studio, I need another way to add an analyzer to roslyn, which lets the compiler issue errors which then get displayed in Unity3D.
Edit2: To be absolutely clear: I already can do UnityEngine.Debug.LogError and print every StyleCop error to the UnityConsole. But I want StyleCop to be integrated in the compilation pipeline of unity. So that I cannot press play anymore.
Here is a solution if you don't mind to write some little pieces of code.
Unity has an editor log file, it records every warning during your build. Like this:
Assets/SomeScript.cs(134,33): warning CS0618: UnityEngine.Random.RandomRange(float, float) is obsolete: Use Random.Range instead.
Unity has a callback IPreprocessBuildWithReport.OnPreprocessBuild , which has the following description:
Implement this interface to receive a callback before the
build is started.
You can start to monitor the log changes from then on.
Unity also has a callback when a build is end, by adding a PostProcessBuildAttribute to a specific function. Here is the description:
Add this attribute to a method to get a notification just after building the player.
[Update]
Now you've recorded if there are warnings in last build, you can make a flag in memory or in file system, then you add few lines of code to check this flag, if it's true then stop the playing by using EditorApplication.ExitPlaymode()
How can I selectively ignore compiler warnings at a folder level without altering the source code files (*.cs)? With the toy example below, I want to ignore CS0001 only for Lib1 (reviewed it to be ok) but nowhere else (since they could be unreviewed). Right now I can ignore compiler warnings only at the project level. Or I need to add #pragma to the source code which makes my source different from the library repository upstream which we cannot directly use (or link).
Project
+-LibSrc
+-Lib1 // Ignore CS0001 here
+-Lib2 // Ignore CS0002 here
+-Lib3
I'm hoping for some sort of project setting or some file places in the folder that signals this to the C# tools.
You can select the files to ignore, on File Properties, set Build Action to None. The compiler would ignore warnings from the files and build.
I am trying to build my setup using the installshield software as in VS2012, you must use it. I have managed to prepare but I have one problem which is these warnings:
Warning 5 -6248: Could not find dependent file u2dmapi.dll, or one of its dependencies of component Aamali_New.Primary_output ISEXP : warning : -6248: Could not find dependent file u2dmapi.dll, or one of its dependencies of component Aamali_New.Primary_output
Actually it looks for this file u2dmapi.dll!! I have managed to download the file from internet but I do not know where to put the file so the builder would find it. I have tried to put it in several location in the project but it could not see it. Can you please help me about the location so it will get it and will not create this warning again. Waiting for your kind reply.
Thanks.
According to this article, you have to place the DLL "in the same location as the key file for the Component specified in the warning." In my case, it was a project output, so I had to put my DLLs in that project's bin folder alongside of the exe (bin\release).
There are many ways to do this:
If it's a managed DLL, add it as a reference in the project. It won't allow you to if it's unmanaged.
If it's not, you must manually copy them wherever they are needed
Or automatically by adding a Post-Build Event Command Line (project properties, build events tab) like so:
copy "$(ProjectDir)lib\$(PlatformName)\Unmanaged\*" "$(TargetDir)"
Where $(...) are predefined macros. Check them out, there are many others.
It's a bit tricky and error prone... I would've prefered a way to just flag the file as a dependency in the project but I didn't find a way of doing that.
The long of it is I built an installer in visual studio that gave me this cheery error when I tried to use the program:
Retrieving the COM class factory for
component with CLSID
{EC10E7E8-797E-4495-A86D-3E9EADA6D5BB}
failed due to the following error:
80040154.
From that it seems I need to embed the manifest in the executable and to do that I should add as a post build event the following:
"$(DevEnvDir)....\VC\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest"
–outputresource:"$(TargetDir)$(TargetFileName)";#1
Well, when I do that and build the solution the event is not being called at all. In fact, I can put any old random text in the pre and post events and no error is ever given nor do I see anything being called.
Is there something that I should be doing differently to make this work?
Additional information:
I'm building from the IDE. And when I toggle the build types to debug and release I still the correct command in the post build events.
Is there a way to see a log of what it's doing?
Tool + Options, Project and Solutions, Build and Run, set "MSBuild project build output verbosity" to Detailed. You'll get a ton of diagnostics in the Output window.
FWIW, the error message you get is a simple "class not registered" error. Fix with Regsvr32.exe
two guesses:
build is not succeeding
your post/pre build events are defined in a project config that is not being built, like you define your events in the "debug" build but are building the "release" build.
are you building the solution from the command line or anything like that?
Here's what worked. You apparently don't need to bake the manifest into the program. It was enough to include the manifest into the msi package and also include the DLL that the dependency checker missed.
Like most things so simple once you know :-)
Why the post build steps aren't being called I don't know, but the real problem is solved.