Looking through Roslyn's documentation, I could not find anything about failing the build. I have currently built an analyzer tool that will look to see if methods are missing a tag and notify the developer with a suggestion to add this tag. But what I want to do is be able to fail the build if they attempt to build the project.
I saw places online where devs have been using: CodeIssue but I do not think this would work.
This would be similar to how stylecop works when it fails the build.
Has anyone found any examples/resources where it can return a build failed with errors?
You can set the compiler options to treat your analyzer's warning ID as an error, just like with built-in warnings.
Related
I tried searching but haven't found an answer. I upgraded SonarQube from 5.6 to 6.3 by taking the steps outlined here: https://docs.sonarqube.org/display/SONAR/Upgrading
SonarQube was upgraded and up and running quick enough, but then some problems occured. New results weren't being imported for alot of projects and even if they are, things aren't looking good.
The broken importing seems to be related to character set differences. I get crashes like: java.lang.IllegalStateException: Unable to read the source file : 'D:/Builds1/SF/CA AanvraagData/Sources/AAHG.AanvraagData.Client/AAHG.AanvraagData.Client.snk' with the charset : 'UTF-8'.
However, I only have the latest C# plugin installed as language plugin. Why is SonarQube even trying to read .snk files? I never had this problem before, and from what I understand SonarQube should only import known filetypes (sonar.import_unknown_files is set to it's default of false). I can manually exclude alot of extensions, but I'd rather not.
The few projects that actually get imported seem to have issues which presenting C# code in testclasses (no syntax coloring). Also the sonarqube runner gives alot of errors like this: Unable to TFS annotate the following file which is not in a mapped TFS workspace. A little further on in the output the annotating does seem to work for the same file all of a sudden. Also, I'm getting debug lines saying stuff like this: 'ontwikkel.config' indexed with language 'null'. Again.. why is it trying to index files other than .cs? Havent looked at these issues since they're minor in comparison which entire projects not importing, but if anyone has a suggestion that would be great.
Things I tried:
- Updating the scanner to the latest version (2.2), but that isnt helping. Reverted back to 2.0
- Manually excluding files - seems to be working to some extend, but I do not want to rely on this. I'm working with 60 other developers..
- Checking upgrade notes to see if I missed anything
- Checking jira for known issues, but I don't really know what to look for
Can anyone help me out here? Thanks!
With regards,
Whistler
There seems to be a bug in SonarQube 6.3 which results in the behavior I'm describing, resulting in projects failing to import when using in/exclusions: http://jira.sonarsource.com/browse/SONAR-8995
The possible answer posted above is wrong.
Cannot debug a project because of this error message.
**
Could not load file or assembly 'Microsoft.SqlServer.TransactSql,
Version=13.0.0.0
**
The project type is a VSIX extension.
I'm guessing that somehow, the VS SQL support has been whacked somehow... but not sure what to do to fix.
I found this in Add/Remove programs, but do not know how they were installed (maybe through VS install?).
My VS Version is:
Please advise.
This line was causing the issues, I wanted to provide a listing of all classes in assemblies to user to see versioning. When I commented it out, problem disappeared.
var types = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetTypes()).ToList();
I still don't know why I have the 2016 SSMS installs, maybe I tried it out earlier this summer. But, oddly why does this line of code above cause the problem? Weird.
I'm trying to build a project in Rider using Mono and I can keep on getting this error:
Error CS0041: Unexpected error writing debug information -- 'Windows
PDB writer is not available -- could not find
Microsoft.DiaSymReader.Native.x86.dll'
Does anybody have any idea why I'm getting this error? I've tried searching for it online and all I could find was a previous SO question that never got answered: Monodevelop fails to build, can't find Microsoft.DiaSymReader.Native.x86.dll'
I have no idea where to start. Any help would be appreciated.
Right, the library exists. but on Visual Studio, using NuGet link to nuget package it will add the reference and add the Microsoft.DiaSymReader.Native.(arch).dll into //debug, once you build it. So, you must find the way to get such .dll.
Once you have the .dll with the arch you need. Proceed to add as a external reference on Monodevelop see this the dll.
Begin to build.
I have a C# PCL project that uses code contracts. However on TeamCity the project fails to build, but it looked like the build was successful locally. However the build log does claim that the build did fail, but it gives no reason at all.
'Fail build on warnings' is disabled.
I get a single strange warning:
CodeContracts: Could not find the method/type
'System.Diagnostics.Contracts.PureAttribute' in assembly '[project
path]\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll'
Searching google gave me one relevant result with someone who has the same problem.
However it has no responses besides bumping.
Build log
I also find this line peculiar:
C:\Windows\system32******.dll (1,1): message : CodeContracts: Checked 3154
assertions: 2821 correct (333 masked)
Why is the binary located in system32? I didn't think MSBuild even had write access to that folder...
The issue seems to be that it by default looks for contract types in Microsoft.Contracts (per spec) which doesn't work because Microsoft.Contracts is not what I am using. I'm using System.Diagnostics.Contracts, which is located in mscorlib. It doesn't tell me this, rather it does something non-sensical. I started looking through the source code and I found the offending code but in my opinion this code is of poor quality, so I gave up on actually finding the issue and creating a pull request.
However the solution is simple when you know: you need to override the default for the contract library which is Microsoft.Contracts with mscorlib, so simply add the following to the command line of the static analyzer:
-cclib mscorlib
This worked for me at least. I still think this is caused by two bugs in Code Contracts:
It fails the build because of a warning.
It tries to locate the PureAttribute in the wrong assembly.
When I try to install IronPython on Debian with Mono (3.12), I get the following error:
socket.cs(1900,63): error CS0117: `System.Net.Sockets.SocketOptionName' does not contain a definition for `IPv6Only'
How can I solve this problem? According to the IronPython website, everything should compile without errors.
In the Mono mailing list there is already such a bug, but there is no answer to this bug. Therefore I thought that maybe this forum is a better place for this question.
I'm no expert on either IronPython or Mono, but out of curiosity I just tried this.
For whatever reason, the IPV6Only value in the SocketOptionName enum appears to be missing in the Mono implementation. The error message you're getting is from the code in IronPython.Module/Socket.cs attempting to reference this. It turns out that this is already recognised in the codebase as a feature that not all platforms have, so there's an easy workaround:
The Common.proj project file in the Solutions/ directory in your git checkout defines a number of possible ReferencedPlatform values. The default value is V4. Just below there in the XML, find a block starting:
<PropertyGroup Condition="'$(ReferencedPlatform)' == 'V4'">
Nested in there is a Features element with a list of the features that apply, and if you find and delete FEATURE_IPV6 at the end of the list, then you should find that the project will build using make. I briefly tried firing up the ipy.exe that is generated and it seems to work.
Obviously this isn't a very good solution. Probably the best thing would be to file a bug report with the IronPython project. I guess that Mono on Linux is probably a fairly low priority for the guys who are working to maintain it.
Correct, up to mono 4.0 throws Protocol option not supported when setting IPv6Only false.
This is probably resolved here: https://github.com/mono/mono/blob/mono-4.2.0-branch/mono/metadata/socket-io.c#L536
But do note the compile flag IPV6_V6ONLY