SonarLint intent clarification - c#

I was searching for an extension to integrate VS with Sonar, in order to avoid waiting for Sonar to run to have a feedback on my code. Live feedback is really valuable in addition to shared feedback through Sonar UI (providing shared ruleset, history, tendance, analysis...).
I had seen plugins for Eclipse & IntelliJ in last years, which were running Sonar analysis (based on shared ruleset), leveraging incremental analysis also...
Lately, I found vssonarextension that seems to do pretty much the same thing (incremental & preview analysis) for C# projects in Visual Studio.
But I also found the official SonarLint (recently renamed from SonarQube for C#), and I can't catch how it works. It seems to be disconnected from SonarQube server and to reimplement rules already implemented on server (through C# plugin), am I wrong ? Can you clarify ?

SonarLint for Visual Studio is based on the new .NET compiler framework (Roslyn), which is shipped within Visual Studio 2015. This extension is working on individual developer machines, and (at the moment) is not connected to the SonarQube server.
To share a set of common rules between developer machines, you can save and commit a ruleset file along with your solution. On each developers machine this ruleset file will be picked up by the .NET compiler framework, and therefore by SonarLint too. (If you don't want to install the SonarLint VS extension, you have the option to ship this functionality along the solution in the form of a Nuget package)
To see the analysis result on a SonarQube server, you would need to use the MsBuild SonarQube Runner (more info). This internally uses the SonarLint assemblies, and adds a few more rules that need parameters that are specified on the server.

SonarLint for Visual Studio integrates with Visual Studio 2015 and provides live feedback, as you code, on quality flaws. It also automatically suggests code fixes. It has no connection with the SonarQube server: you won't be able to see for example all new issues introduced since the last SonarQube analysis, comment on issues, and so on. We're working with Microsoft to improve that overtime.
vssonarextension is an unofficial Visual Studio extension (also ) for SonarQube. It is not developed and not supported by SonarSource. My understanding is that this extension is an attempt to replicate the Eclipse / IntelliJ SonarQube plugins
Speaking about the Eclipse / IntelliJ SonarQube plugins (soon to be rebranded into SonarLint for Eclipse / IntelliJ) - these are both in advance of SonarLint for Visual Studio, because they have this connection to the SonarQube server, but also lag behind because of the lack of real-time (or close to real-time) feedback. The Eclipse SonarQube plugin has a new feature to analyze files each time they are saved, improving the experience. Moreover, none of two is able to suggest code fixes for now.
The MSBuild SonarQube Runner is not simply a "wrapper" around the sonar-runner: It captures information about your project during the actual msbuild build, forces the FxCop execution, and so on. Yes, in version 1.0, the end phase will invoke the sonar-runner, but this really is just an implementation detail. Newer versions of the SonarQube server will allow analysis reports to be uploaded through a web service, instead of relying on direct accesses from the sonar-runner to the database. So in the future, we can imagine a pure C# implementation of the MSBuild SonarQube Runner, which could work without having to install Java.
The SonarQube C# Plugin is providing C# support in SonarQube. You obviously cannot install SonarLint for Visual Studio in SonarQube, as it is an extension for Visual Studio 2015... Now, the SonarQube C# Plugin internally embeds some version of SonarLint VS: It launches a Windows executable that will re-use the same .dll files that the Visual Studio extension uses. This way, there is not need to duplicate the rule implementations.
Feel free to have a look at the sources if you want more details on how this works exactly:
https://github.com/SonarSource/sonar-msbuild-runner
https://github.com/SonarSource/sonarlint-vs
https://github.com/SonarCommunity/sonar-csharp

Related

can we use visualstudio 2010 soucecode in visualstudio 2019?

my client using visualstudio 2010 for his application and app OS version is windows 7. they shared the sourcecode of that application and asked me to migrate that code into VSTS. but, i am using visualstudio 2019 with OS version windows 2010 in my system. can we use that sourcecode in my system. any compatabilities are there ?
Yes, but you will most likely have to adjust for the target runtimes/frameworks and configuration differences that the VSProject file will have between the versions. The VSProject file will almost certainly migrated to the latest version for VS2019.
You may not be able to if the target runtime/framework for the application is not supported by VS2019. For example, if it something less than .NET 4.5.2, you may run into problems.
The best solution is for you to get his system, his version of VS and the code base updated to the latest. If this will be a significant effort on your part, tell your client that migration will be a billable item.
If you're merely trying to share code, write, but not build anything you can certainly use VS2019, but at that rate, you may as well us VS Code.
There is no such thing as visual studio 2010 source code. THere is source code, that has been written in VIsual Studio, but a .cs file is a .cs file, regardless of the editor. A text file is a text file. Source code is not like word, where there are a ton of formatting information embedded in a file format that is complex - source code are SIMPLE text files.
2010 to 2019 MAY be a little large for the project file - you have to try it out. That being said, making new project files is trivial.
2010 likely (not sure, it is like ages ago) does not use nuget - you likely run into more problems with .NET versions and links to third party libraries.

Additional Setup in Visual Studio Installer Projects

I am trying to create an installation for my project. I am using MS Access DataBase and for it to work Access DataBase Engine is required. If i download that engine https://www.microsoft.com/en-us/download/details.aspx?id=54920 from here and install it, program works.
How can i add that installation to my installation?
I am using Visual Studio 2015, C# and OLEDb.
Short Version: In essence you will need a deployment tool. List view of major deployment tools. Maybe that list view is the easiest overview? (a sense of scope). Much more detail below (and too many links too).
Details: There is some prerequisite functionality available in Microsoft Visual Studio 2017 Installer Projects, but I am unfamiliar with the details. I find this project type inadequate for real deployment work for a lot of reasons (lacking features and some odd implementations). More on this here - a few concrete problems to consider.
Several commercial tools will do this for you with special features to help make it quick(er). I verified that Advanced Installer can do it (and here is a great gateway to all things Advanced Installer. Some free features available). I assume Installshield can do it as well (certainly for other runtimes, didn't verify this particular one). Generally it will be handled by a setup.exe bootstrapper / chainer embedding all runtimes along with your own MSI file(s).
In other tools, you will have to do it yourself, by figuring out command lines and how to handle error conditions. There are some hints here (not tested by me - a google sweep will give you more): https://www.itninja.com/software/microsoft/access-runtime/2016-1
Get more command line info by going accessruntime_4288-1001_x64_en-us.exe /?:
WiX is free and open source - with a relatively hefty learning curve if you don't know MSI, and contains a bootstrapper feature called "Burn". Here is the documentation for: How To: Install the .NET Framework Using Burn (first read the "Building Installation Package Bundles" instructions in "Step 1"). A real-world Burn sample. And some sample source markup.
Some developers recommend the dotnetinstaller bootstrapper. Not something I know much about. It is just a bootstrapper. Runs things in sequence for you.
If you are doing in-house or ad-hoc deployment, even a batch file could do the job I suppose, but if you do that for a real product for large-scale and generalized deployment I would be very worried indeed. If there is one thing we hate as deployment specialists, I'd say it is batch files embedded in packages. Batch files (and scripts) are system administrator tools, not general deployment tools.
Some Older Links:
Executable files to MSI installer
How do Installation Software Programs Extract Files?
Create MSI or setup project with Visual Studio 2012
How to make an installer that automatically install all the prerequisite programs for the application
Windows service NOT shown in add remove programs under control panel
How to make an installer that automatically install all the prerequisite programs for the application
Wix - How to run/install application without UI
Visual Studio setup projects have a Prerequisites choice in the project's properties. This allows you to choose from a list of standard prerequisites and generate a setup.exe that will install the prerequisites and then install your MSI. The Access Runtime doesn't appear in later versions of setup projects because (I assume) Access 2013 ended mainstream support in 2018. The way to add your own prerequisites to this mechanism was with the Bootstrap Manifest Generator, which is perhaps still available but not well documented:
https://msdn.microsoft.com/en-us/library/ms165429.aspx
Apart from that I'd recommend that you learn how to build a WiX Burn bootstrapper executable that will install the Access Runtime and then install your MSI (which you still build with Visual Studio if you need to). If you do a search for that you'll find this kind of thing:
WiX - Install Prerequisites and 3rd party applications
https://www.c-sharpcorner.com/UploadFile/cb88b2/installing-prerequisites-using-wix-bootstrapper-project-and/
These will explain how to build the Xml to check whether the Access Runtime is installed and the command to use to install it. This is a much better choice than the Bootstrap Manifest Generator.

Wrap C# application in .msi installer

I have created a C# application in Visual Studio 2017. Now I would like to distribute my application as a single windows installer file.
I was hoping for a simple one-click solution (select all the files I want to include -> voila! there's the installer). But it seems to be not that easy :-(
I often read that Visual Studio supports setup projects. But that does not seem to be the case anymore, right?
Third party tools are either very complicated (e.g. Wix, Inno Setup) or very expensive (e.g. Advanced Installer).
Is there really no simple way to wrap some files in an .msi Windows installer?
Does Microsoft provide no tooling to create such installers?
At one point, Microsoft did remove the "Visual Studio Installer Project" support from Visual Studio1. And then they later relented and added support back. I can't remember which versions didn't have support, I think it was 2012 and 2013.
These days (for VS2017), to get the Visual Studio Installer Project support, you add it from the marketplace:
This extension provides the same functionality that currently exists in Visual Studio 2015 for Visual Studio Installer projects. To use this extension, you can either open the Extensions and Updates dialog, select the online node, and search for "Visual Studio Installer Projects Extension," or you can download directly from this page.
Personally, however, I'd go with WIX. It does have a learning curve but I think it's learning worth doing.
1For what I personally see as very good reasons. You had to have a full-blown install of Visual Studio to make them work, they didn't really integrate with MSBuild, which makes them a pain if/when you want to move to automating your builds.
VS Installer Projects: Several good answers already - worth trying out. As stated by others you can use Microsoft Visual Studio 2017 Installer Projects - as limited as they are (bullet list form). They feature some pre-requisite functionality as I recall. I have limited experience with the tool. Could work for something very simple, but you will quickly discover limitations.
WiX: Personally I would use WiX since it is also free and flexible - it takes some effort, but is very capable. Here is a WiX quick start tip answer (frankly not my favorite answer, but it has been upvoted more than usual and updated frequently - hopefully it still has its essence of helpfulness).
IsWiX: There is also IsWix - a GUI tool to help create WiX setups (Chris Painter's work). His WiX tutorials and a quick youtube demo.
Et Al: The commercial tools (Installshield, Advanced Installer (see Bogdan's answer in this "thread"), PACE Suite, etc...) are also good - your time costs too. Can be shocking once you add it up - and you will definitely get running quicker with a commercial tool. How to create windows installer (links to pretty comprehensive lists of tools and some MSI information). Further links below.
Other than that, I'll just link to a few pre-existing answers with info about various tools:
Quick review of different MSI tools
What installation product to use? InstallShield, WiX, Wise, Advanced Installer, etc
or very expensive (e.g. Advanced Installer).
There is a also a free edition which includes a Visual Studio extension for Advanced Installer, which you can use to build MSI packages.
The following tutorial shows how you can use the features from the free edition ("Simple" project type):
https://www.advancedinstaller.com/user-guide/tutorial-ai-ext-vs.html
https://www.advancedinstaller.com/user-guide/tutorial-simple.html
P.S. I work on the team building Advanced Installer.

Remove Auto-generated Code from SonarLint Analysis

Background
I am running Visual Studio 2015 Enterprise (RTM) and have enabled the SonarLint extension for code analysis of my multi-project ASP.NET 4.5 MVC solution.
Problem
SonarLint analysis seems to be ignoring the project setting for Code Analysis "Suppress results from generated code (managed only)"
That is, I'm getting a lot of Sonar errors reported back for a couple of *.designer.cs files generated from some .aspx pages. (Most of the project is MVC, for what it's worth.) I don't care about these errors, and don't think I have a decent path for fixing them...
More Details
I have SonarQube integrated with our TFS 2013 environment, and it is correctly ignoring these issues on the TFS server analysis. This problem is just showing up in Visual Studio, using the Roslyn analysis.
Any ideas how I can set up the equivalent of an .ignore file or otherwise fix this?
There is no built-in way of ignoring files in Roslyn at the moment, so you can't do it. Each analyzer needs to decide if the analyzed file needs to be checked or not. Specifically for SonarLint, I've created an issue on GitHub: https://github.com/SonarSource/sonarlint-vs/issues/85. You can track its progress.

visual studio: what is sourcesafe?

what is sourcesafe?
i am trying to download it to see if it will work well with c# because someone told me to download it for a job, but i don't even understand what it is?
is it built into the visual studio ide or what?
SourceSafe is a poor and obsolete source control system.
It can store an application's source code and show revision history, and allow multiple developers to work on the same project efficiently.
It has been replaced by Team Foundation Server.
Sourcesafe is a version control system from Microsoft, some would say not a very good one. It's not part of Visual studio however it does integrate into it. MS have now replaced VSS in their Team System version of Visual Studio.
Source control is a great idea, and experience with them will definitely help your Job hunting, but don't constrain yourself to Sourcesafe, also checkout (pun intended) systems like Subversion etc.

Categories

Resources