I just want to try OpenCover to get Coverage statistics from my app.
But I don't understand well how to use it. So here my questions?
Does the dll's have to be in the same directory? (my solutions have several projects)
Any example to get Coverage using OpenCover?
Is necessary to run the site in IIS Express or with ASP.NET development server is ok?
Thanks a lot!
I set up open cover as an external tool to make it easier on me.
Download the exe and drop it in a folder with as short a path as possible. then setup and external tool as follows:
Title : Open Cover {this is your choice}
Command: {your path to opencover}\OpenCover.Console.exe
Arguments: -register:user -target:"C:\Progra~1\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" -targetargs:"$(TargetName)$(TargetExt)" -output:coverage.xml -targetdir:"$(ProjectDir)\bin\debug"
Initial directory: $(TargetDir)
Set it to use output window and close on exit. You will need to adjust the test runner program to suit you, i use vs2012, if you do too, that will make it easier on you.
To use it, click your test project in your solution explorer, then click on the open cover external tool and it will generate you the coverage report. I use it with Report Generator.
Set it up as an external tool too:
Title: Report Generator
Command: {Your path to report generator}\ReportGenerator.exe
Arguments: $(TargetDir)coverage.xml $(TargetDir)\coverageResults
Again, set to close on exit and use output window.
after generating your coverage report, you can then use report generator to create a nice looking html version that you can click through and see the stats.
hth
The docs that are installed alongside OpenCover carry a lot of useful information about running OpenCover. You should have a copy of this file https://github.com/sawilde/opencover/blob/master/main/OpenCover.Documentation/Usage.pdf in you download package (MSI/ZIP/NUGET)
The DLLs do not need to all be in the same directory but you will normally find that this happens due to the build process. Any assemblies that you want to gather coverage from will require that the PDBs for those assemblies to be in the same directory as the assembly or in the folder referenced by targetdir switch.
Yes you can use it to run iisexpress or the ASP.NET development server use the target switch.
Related
We're using Visual Studio Team Services with Git as the source control system and I've configured a build which executes successfully online. Ideally I'd like to:
After building the site in VSO, precompile and dump the aspx and .dll files to the git repository
On the on-premises web server, pull from git and move to our staging site
The second part I can figure out on my own, but the documentation for VSTeam seems sketchy on how to dump the compiled sources to git. I've kept the default build configration almost the same as the default with the exception of a Powershell script which is supposed to create artifacts for the drop. Despite this, the drop.zip file create is empty.
The following is how my build definition is set up in VSO.
Instead of the PowerShell script, you'd be able to use the "Copy and Publish artefacts" and have it create a specific artefact with the specific bits you need:
This will automatically create a named build artefact which you can then use from Release Management as an input.
The PowerShell script was used in the XAML builds when used with the "Project Output | As Configured" option.
To create your "packaged" website, you need to add a couple of parameters to the MsBuild/Visual Studio Build step to instrict the compiler to package your website:
/p:DeployOnBuild=true /p:DeployTarget=Package
/p:SkipInvalidConfigurations=true /p:PackageAsSingleFile=false
/p:AspNetCompileMerge=true
Optionally you can configure your target directory as well using
/p:PackageLocation="$(Build.BinariesDirectory)\Published"
If you do this, you need to configure this directory as your copy root in the copy and publish task.
I did a quick look at the Power-Shell script, there are two issues with it:
It still use the variables like "$Env:TF_BUILD_SOURCESDIRECTORY" which does not exist in VSTS(VSO). See Variables for VSTS.
It copies the files from "BUILD_SOURCESDIRECTORY" folder to "BUILD_BINARIESDIRECTORY". But the "Publish Build Artifacts" step in your definition publish the files in "BUILD_ARTIFACTSTAGINGDIRECTORY" folder.
So if you want to use this script, you need to update the script to remove the "TF_" string in the variables and update the "Publish Build Artifacts" step to publish the files in "BUILD_BINARIESDIRECTORY" folder(Set Path to Publish to: $(Build.BinariesDirectory)).
However, if you want to copy and publish the website files, you can simply add one more argument in "MSBuild Arguments" section of "Visual Studio Build" step:
"/p:outdir=$(build.artifactstagingdirectory)"
Remove the Power-Shell script step and the other steps just keep default settings.
Or you can also change the settings of "Copy Files" steps to select the files/folders you'd like to copy.
I have read articles on build automation and it looks simple, but I am really not sure about parameterized build. I believe, there must be a xml file for that.
When we say build is automated, I believe it means our code/binaries sit in test environemnt. And all application related settings will also configured just by simple clicks of build, and push.
What are the required tools? What is MSBuild ?
Please put some light on it.
MSBuild is and exe that you run with command line tools and pass to it the project file (.csproj) which is an XML file as you said and it has all the instructions needed as you configured.
I created a series of videos that describe how to create simple MSBuild tasks and how to organize tasks and so on, for more info click on the following link:
MSBuild Tutorial
MSBuild is exe
When you run MSBuild from Command line
You will need to unload the projct so you can edit the (.csproj) or project file
The (.csproj) or project file
You are asking about build automation, and by your tags you menation TFS 2010 if so then you only need a cursory understanding of msbuild to get started. It is what eventually calls the compiler, but in all hoensty you need the step above it which are the build templates and defintions, along with how to set up agents and controller.
Here is a good overview document by Martin Woodward, this should give you enough to figure things out, or ask more specific questions
I have a website with lots of files using team build and deploying though web deploy packages. The problem i am having is that the packages are build from one of the machines from the farm and the time stamp will not always match. By default with web deploy that means a full site roll and with so many file and the sync across the cluster this is not optimal.
With cmd line deploy i can pass -UseCheckSum and this is solved for manual deployment. Now i'm trying to use a CI build with auto deploy and passing MSbuild arguments though my build setup. Is there a way to get this to deploy in the same manner?
You can't do it in your MSBuild, but you can edit the Microsoft.Web.Publishing.targets file on the build server to apply -UseChecksum.
See my answer here: https://stackoverflow.com/a/13863041/8037
UPDATE: MS has added the ability to pass the UseChecksum flag to VS 2013. To do this, add the following property to the .pubxml file:
<MSDeployUseChecksum>true</MSDeployUseChecksum>
Further information can be found here: http://blogs.msdn.com/b/webdev/archive/2013/10/30/web-publishing-updates-for-app-offline-and-usechecksum.aspx
If, by "MSBuild" you mean the Web Publishing Pipeline, then the answer is no. The MSDeploy msbuild task supports a UseChecksum property, but the WPP targets provide no mechanism through which you can set it. This is also true of a number of other features (like stored credentials).
I'm using Microsoft Web Deploy to publish and update my site. (script is generated with Visual Studio). This tool removes auto-generated files and folders on update, as they are not included into install package. How to make it keep these files?
The Web Deploy command line tool has two switches that may be useful: -skip and -enableRule:DoNotDeleteRule. For information on -skip, see Web Deploy Operation Settings, and for DoNotDeleteRule, see Web Deploy Rules.
In Visual Studio, you may be able to tweak the deploy.cmd file to use these to achieve what you want. For more information, see How to: Install a Deployment Package Using the deploy.cmd File.
Having to edit the deploy.cmd files each time you generate them is a pain. I am using VS2017 and found I can set an environment variable on the server and deploy.cmd will use it. The deploy readme file says it:
Alternatively, you can specify additional flags by setting the
"_MsDeployAdditionalFlags" environment variable. These settings are
used by this batch file.
So on the server I created the environment variable:
_MsDeployAdditionalFlags=-enableRule:DoNotDeleteRule
And that did it. It now adds the rule each deploy on the server.
I want to know if there is any addin to synchronize files with a remote server (like a file upload (FTP) for deployment). (in a Website)
Something that can identify the files I change and check them for a later upload.
Is there an addin for that?
That sounds remarkably like source control to me... and there are lots of source control add-ins for Visual Studio.
Even if you don't really want the full power of source control, it can be a pretty simple way of syncing with another machine... in fact, that's how I end up "deploying" to csharpindepth.com - I check everything into a repository on the server, and a hook updates the web site directory.
You are probably looking for something like this. Dispatch is pretty good indeed, but it´s not a free alternative.
If you are talking about just file syncing and not source control, then Microsoft's Live Mesh is the tool for you. It will sync files across whatever devices you want - quite handy if you need to take work home with you but don't have remote access to your source control (or you do but don't want to be checking in stuff that is still WIP).
Note that it isn't a VS plugin, it operates separately and watches for file system changes.
What do you mean by synchronize files? Synchronize with what?
If you mean with a repository, then ankhsvn is one such add-in that works with subversion.
If you mean with the deployment location then clickonce is built-in and manages file versioning on the server whenever you click 'publish'.
edit>
ClickOnce calculates all necessary dependencies for the project. Additionally, you can click the 'application files' button in the publish tab of project config and select 'show all files'. For each file you can mark them as:
include: They'll be deployed with the project
Pre-requisites: they must be on the system at the time of installation/deployment
Exclude: Don't deploy them
Likewise, the pre-requisites button allows you to ensure that certain application dependencies are present (framework version, sql server is installed, etc.).
AnkhSVN http://ankhsvn.open.collab.net/ is an integrated Subversion interface and as with all version control systems you can check in code (and other files as well). I would recommend something of that nature unless you synchronization files are not project related, in which case I recommend pretty much any of the file synchronization utilities that are available out there. I'm partial to Delta Copy http://www.aboutmyip.com/AboutMyXApp/DeltaCopy.jsp for general purpose file copies.