How can we get code coverage for multiple applications in a single Visual Studio solution using dotCover? (command-line) - resharper

Here are JetBrains' instructions for a single application:
<?xml version="1.0" encoding="utf-8"?>
<AnalyseParams>
<TargetExecutable>D:\Program Files\NUnit 2.6\bin\nunit-console.exe</TargetExecutable>
<TargetArguments>AppTests.dll AppTests2.dll AppTests3.dll</TargetArguments>
<TargetWorkingDir>D:\Projects\TheApplication\bin\Debug</TargetWorkingDir>
<Output>AppCoverageReport.html</Output>
<ReportType>html</ReportType>
</AnalyseParams>
source: https://www.jetbrains.com/help/dotcover/Running_Coverage_Analysis_from_the_Command_LIne.html
Our Visual Studio solution has multiple applications (in a single Visual Studio solution) that we want to get code coverage for in our Jenkins build. We are looking to integrate this into our CI/CD pipeline (so seeking a command-line solution). This is analogous to running cover on the entire solution inside Visual Studio IDE.
(The applications obviously share common library projects, but we want all C# projects to be reported once each. We prefer to avoid manually maintaining multiple XML configuration files and merging the results, i.e., one XML per C# project, as we have 50+ projects.)

Related

Why duplicate folders in an Android project?

I've found out that over a course of several years, a lot of programs keep seemingly duplicate "project folders" in the Android Studio, why is that?
To elaborate a bit further, if you import their projects, and if you take a look at there folder structure, there is going to be something like this:
Java
|--com.myproject.spaceInvader
|--com.myproject.spaceInvader(test)
|--com.myproject.spaceInvader(alphaTest)
What are these? Something generated by 3rd party testing tools?
When you create a project in Android Studio, it has a standard structure:
From official documentation:
main
Contains the "main" sourceset files: the Android code and
resources shared by all build variants (files for other build variants
reside in sibling directories, such as src/debug/ for the debug build
type). AndroidManifest.xml Describes the nature of the application and
each of its components. For more information, see the
AndroidManifest.xml documentation. java/ Contains Java code sources.
test
Contains code for local tests that run on your host JVM.
androidTest
Contains code for instrumentation tests that run on an
Android device. For more information, see the Android Test
documentation.

How do I transfer a Azure Function script to Visual Studio?

If I create an Azure Function in the Azure portal, how do I grab the script and edit it in Visual Studio? I know I can copy the C# code from the script window but that's only part of the Function. How do I grab everything - the code, triggers, outputs, etc. - and take that into Visual Studio?
There's a button right in the Function App blade in Azure that allows you to download the contents of the function app:
You can even choose to download the Content and the Visual Studio project so you can directly import it into VS. However, as Travis mentioned you should really be doing this the other way around and keeping your development in VS and then using one of the various deployment options to push your functions to Azure.
You can use FTP or Kudu(.scm.azurewebsites.net) to download the app contents.
Generally speaking though if you want to work in Visual Studio it's better to do your work there and then deploy to the app with one of the several deployment options.
Once your migrate the files (as noted in the other answers), you'll also note that Visual Studio encourages a different programming model than the portal:
Precompile *.cs instead of .csx
Instead of Function.json, you use the attributes (ala WebJobs SDK).
So to fully work in VS and leverage the VS build system (and unit tests, and other VS features), you'll need to migrate your code.
See https://blogs.msdn.microsoft.com/webdev/2017/05/10/azure-function-tools-for-visual-studio-2017/ for more detail on webjobs.

CMAKE changing Visual Studio Settings

I've been using CMAKE recently on Linux and Windows and I really like it. Its a great way of spinning up a project and organizing your builds. There are just a few things that are bugging me and I'm hoping to get help here.
Visual Studio Settings
Everytime CMAKE generates a project it will be a fresh solution and will not maintain any of the settings you applied to the Visual Studio project. I know that many things such as CMAKE_CXX_FLAGS, etc can change the properties. But what if I want to change settings such as "Suppress Startup Banner", "Environment", Enabling Microsoft Symbol Server, Enabling Native Code Debugging. How do I force CMAKE to set the options I want for fields like these?
Combining Debug/Release/Etc into one solution
It seems that with CMAKE you have to do separate generations for Debug/Release/etc. But in typical manually created Visual Studio projects you can combine the profiles and just change a project setting to get your new settings. Is it possible to generate a single solution file from CMAKE?
Okay so I scoured the CMAKE boards as well. Here are the answers I found.
Visual Studio Settings
For this one CMAKE can't modify the *.user files at all. However what was proposed was to make a user file template and then use CMAKE to supply all the paths and such that you are concerned with. This worked very well for me.
Combining Debug/Release/Etc into one solution
To change various settings on a per configuration basis. It seems like it is best to use fields like CMAKE_CXX_FLAGS_ and most importantly generator expressions. Generator expressions allow you to test for the build type and then generate whatever include, libraries, etc that you need.
Take a look at "Generator Expressions" here

Missing Deployment Project Type in Visual Studio 2012

I am not a full time programmer, but have to do a little bit to build tools to support my job. I have finished writing my application which I now need to deploy.
I do not want to use "ClickOnce" as I need to alter files in the 'local' folder at configuration time. My understanding is that if I use the Publish option under the Build menu, then I am using "ClickOnce".
My research has led me to believe that "You do this by adding one or more deployment projects to your solution". MSDN then states, that to acheive this I need to select 'Add Project' and "In the resulting Add New Project dialog box, select the Setup and Deployment Projects folder."
The problem is, I do not have such an option ?!
Can someone shed some light on why this would be the case, and how I go about fixing it. I have spent half a day googling and cannot come up with a way forward?
Details of Project and System are as follows:
Environment: Visual Studio 2012 Express for Windows Desktop.
Current Project: Windows Form Application.
Op Sys: Windows 7 Professional.
Correct though its advice may be, that is an old tutorial that you're reading. It is probably referring to Visual Studio 2010.
That option has been removed in VS 2012. You will need to use an alternative tool to build your installer. For example:
WiX
Inno Setup
InstallShield
…etc.
I strongly suggest looking at Wix#. See http://www.codeproject.com/Articles/31407/Wix-WixSharp-managed-interface-for-WiX. If you are doing your coding in C#, Wix# this would probably be the most simple and comfortable skill set to add, and it is free and would directly integrate into the Visual Studio environment you are using.
More info at the CodePlex home page for Wix#: http://wixsharp.codeplex.com/
For C# developers needing to create a Windows Installer MSI to deploy their app, Wix# is perhaps the best replacement for the "Packaging and Deployment" project type that Microsoft removed from Visual Studio starting with VS2012. Wix is a C# front end for the WiX (Windows Installer Xml) Toolset. Using Wix# allows building a complete Windows Installer MSI in the C# language.
Wix# is useful for a broad range of installation/deployment scenarios, and lends itself reasonably well to Continuous Integration scenarios. There are Wix# examples for deploying Windows desktop applications, for installing Windows Services, and installing ASP.NET websites, and many more types of installations.
The question mentioned a need to install applications on Windows 7. Wix# supports this environment, and handles typical installer requirements, and the Wix# installer code for simple projects is indeed simple. For application installs that are more complex, and require advanced features, Wix# can tap into the power of the full WiX Toolset when needed. For example, when installing a .NET application, a typical requirement would be to install the application exe and dll files, and tailor some .NET configuration files and/or registry entries on the target system.
Below is an example of the C# code for a simple Wix# installer that installs an application on a target system, and modifies some configuration files. This example assumes that you have written a utility named "TailorMyConfig.exe", e.g., a simple C# program that uses ConfigurationManager.AppSettings routines, and you are deploying this exe along with your app.
using System;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Deployment.WindowsInstaller;
using WixSharp;
class Script
{
static public void Main(string[] args)
{
var project = new Project("MyProduct",
new Dir(#"%ProgramFiles%\My Company\My Product",
new File(#"Files\Bin\MyApp.exe"),
new File(#"Files\Bin\TailorMyConfig.exe")),
new ManagedAction("UpdateConfigFile"));
project.Id = new Guid("6f330b47-2577-43ad-9095-1861ba25889b");
Compiler.BuildMsi(project);
}
}
public class MyCustomAction
{
[CustomAction]
public static ActionResult UpdateConfigFile(Session session)
{
if (DialogResult.Yes == MessageBox.Show("Config file update ready to run.\n Update config file(s) now?",
"Config Tailoring Utility",
MessageBoxButtons.YesNo))
{
Process.Start("TailorMyConfig.exe", "Run utility to tailor config file to current system");
}
return ActionResult.Success;
}
}
Note that there are "better" ways to modify a config file using WiX XML features. For simplicity, the example above assumed a custom-written C# exe utility for modifying config files. I would suggest using WiX XML capabilities for doing this instead. You can incorporate nearly any WiX XML capabilities directly into your Wix# setup using the Wix# technique of "XML injection".
Remember, Wix# is simply a C# front end that emits WiX XML syntax. After Wix# has emitted the WiX XML (wxs file), that wxs file can easily be post-processed to insert additional WiX XML features. Then the resulting wxs file gets compiled by the WiX Toolset into an MSI.
For an example of using XML Injection to incorporate WiX XML features into a Wix# (C#)installation, look here In Wix#, how to avoid creating a physical folder on the target system, when deploying only registry entries?
In that question, see my answer that uses the technique of hooking up a delegate to the "WixSourceGenerated" event.
You could then use this XML injection approach to insert some WiX XML into your installer that would accomplish the config file editing. An example of some typical WiX XML to modify config files is here:
How to modify .NET config files during installation?
Another typical requirement of an installer would be to add or modify Windows Registry entries on a target system. Wix# provides direct support for that using the "RegValue" class. The advantage there is when using Wix# you also get a full "uninstall" capability for free, including uninstalling/reverting registry entries to the pre-install state. This is a natural result of Wix# being built on top of the WiX Toolset and Windows Installer technology. An example of a registry-only Wix# installer is here: In Wix#, how to avoid creating a physical folder on the target system, when deploying only registry entries?
The Wix# approach has been very useful in my environment, and it allows use of the familiar C# skillset without having to jump headfirst into the full complexity of the WiX XML installer technology.

Visual Studio 2012 speed big solution

Can you please advice how I can speed up a compiling, loading big solution (~50 projects).
I mean only VS 2012 studio or Windows settings, not hardware changes.
Thanks
Consider your need for 50 projects in one solution - having many projects that are referenced by each other is one of the main reasons for slowdowns.
One of the few valid reasons to have separate projects is because you need to deploy the generated assemblies separately. If this is not the case, consider combining projects - use folders for the logical separation.
The lower the number of projects, the faster your build will become.
In addition, if you change the builds to output to a specific shared directory and reference the DLLs instead of the projects, the number of unneeded re-compilations should go down drastically, though you will have to manage the build order yourself.
I use 100+ projects in a solution with Visual Studio 2012 Update 3, and it builds fast.
I agree with shared output directory comment by Oded, but I'd like to mention that project references work OK too.
Make sure that your \Users\\AppData\Local\Microsoft\WebsiteCache folder is empty. Somehow, this is a problem even with desktop-only solutions.
I have disabled Productivity Power Tools 2012, since they compile code in the background, a bit too much for my liking. Disable all plug-ins and extensions and see if it makes any difference.
Suppress excessive output messages to disk and to screen by reducing output verbosity
Use multicore with MSBuild.
As you code, try to limit dependencies between projects by using interfaces and abstract classes (C#).
Try fresh *.suo and fresh *.sdf files. (Make a backup of the user settings and DB, then remove them and try building again)
When all else fails, use ProcessMonitor or attach with another instance of Visual Studio to profile your Visual Studio while it's building.
Try excluding file system filters, such as antivirus, from your build. For example, some antiviruses have a way of skipping scanning in certain directories or by file names.

Resources