Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #613 from sawilde/dotnetcore_595
Browse files Browse the repository at this point in the history
Support .net core portable pdb format (and other issues)
  • Loading branch information
sawilde authored Apr 24, 2017
2 parents 87eb455 + f3b721e commit 3273476
Show file tree
Hide file tree
Showing 57 changed files with 830 additions and 409 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
/fakes/packages
!fakes/packages/repositories.config
/results.xml
.vs
project.lock.json
*.opendb
!/tools/Mono.Cecil/**

#release-notes
/main/OpenCover.Packages/nuget/opencover/readme_with_releasenotes.txt
Expand Down Expand Up @@ -85,6 +89,3 @@ coverity.zip
/samples/SampleSln.zip
/main/OpenCover.Packages/chocolatey/opencover/tools/chocolateyInstall.ps1
/main/OpenCover.Packages/chocolatey/opencover.portable/tools/chocolateyInstall.ps1
/main/.vs
project.lock.json
/main/*.opendb
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ Please refer to the wiki - [Silverlight support](https://github.com/OpenCover/op
### Building
You will need:

1. Visual Studio VS2015 (Community Edition) or later with C# and C++ (with Service Pack 2)
2. WiX 3.10 or later (http://wix.codeplex.com/releases/view/619491)
3. SpecFlow for Visual Studio 2015 (https://visualstudiogallery.msdn.microsoft.com/c74211e7-cb6e-4dfa-855d-df0ad4a37dd6)
1. Visual Studio VS2017 (Community Edition) or later with C#, C++, .Net Core
2. WiX 3.11 or later (http://wixtoolset.org/releases/) and Votive 2017 (https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension)
3. SpecFlow for Visual Studio 2017 (https://marketplace.visualstudio.com/items?itemName=TechTalkSpecFlowTeam.SpecFlowforVisualStudio2017)
4. Windows SDK 10 and .NET Framework Tools (https://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx)
5. Microsoft .NET Framework 4.6.2 Developer Pack (https://www.microsoft.com/en-us/download/details.aspx?id=53321)

Expand Down
7 changes: 3 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 4.6.{build}
skip_tags: true
os: Visual Studio 2015
image: Visual Studio 2017
shallow_clone: true
environment:
COVERALLS_REPO_TOKEN:
Expand All @@ -20,8 +20,6 @@ nuget:
disable_publish_on_pr: true
install:
- ps: >-
cmd /c rd /s /q "C:\Program Files\dotnet\sdk\1.0.1"
Write-Host 'Downloading Microsoft .NET Framework 4.6.2 Developer Pack...'
$exePath = "$($env:USERPROFILE)\VSIsoShell.exe"
Expand All @@ -32,7 +30,8 @@ install:
cmd /c start /wait "$exePath" /q /norestart
before_build:
- appveyor-retry dotnet restore .\main\OpenCover.Simple.Target.Core -v Minimal
- ps: >-
#do nothing
build_script:
- ps: >-
if ($env:APPVEYOR_SCHEDULED_BUILD -eq "True" -or $env:APPVEYOR_REPO_BRANCH -eq "coverity") {
Expand Down
89 changes: 50 additions & 39 deletions build/opencover.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,26 @@
<property name="exclude-admin-only" value="--where:cat!=AdminOnly" />
<property name="exclude-admin-only" value="" if="${appveyor=='True'}" />

<property name="msbuild.exe" value="${program.files.x86}/MSBuild/14.0/Bin/MSBuild.exe" if="${directory::exists(program.files.x86 + '/MSBuild/14.0/Bin')}" />
<property name="msbuild.exe" value="${netfx4.folder}/MSBuild.exe" unless="${property::exists('msbuild.exe')}"/>
<property name="msbuild.exe" value="${program.files.x86}/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe" if="${directory::exists(program.files.x86 + '/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin')}" />
<property name="msbuild.exe" value="${program.files.x86}/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin/MSBuild.exe" if="${directory::exists(program.files.x86 + '/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin')}" unless="${property::exists('msbuild.exe')}" />
<property name="msbuild.exe" value="${netfx4.folder}/MSBuild.exe" unless="${property::exists('msbuild.exe')}"/>

<property name="nunit-console" value="${nunit.path}/nunit3-console.exe" />
<property name="dotnet.exe" value="c:\dotnet\dotnet.exe" if="${directory::exists('c:\dotnet')}" />
<property name="dotnet.exe" value="dotnet.exe" unless="${property::exists('dotnet.exe')}"/>

<property name="nunit-console" value="${nunit.path}/nunit3-console.exe" />

<choose>
<when test="${appveyor=='True'}">
<property name="nunit-console" value="nunit3-console.exe" />
<property name="nunit-appveyor" value=";format=AppVeyor" />
</when>
<otherwise>
<property name="nunit-console" value="${nunit.path}/nunit3-console.exe" />
<property name="nunit-appveyor" value="" />
</otherwise>
</choose>

<choose>
<when test="${appveyor=='True'}">
<property name="nunit-console" value="nunit3-console.exe" />
<property name="nunit-appveyor" value=";format=AppVeyor" />
</when>
<otherwise>
<property name="nunit-console" value="${nunit.path}/nunit3-console.exe" />
<property name="nunit-appveyor" value="" />
</otherwise>
</choose>

<target name="clean" description="Delete all previously compiled binaries.">
<delete>
<fileset>
Expand Down Expand Up @@ -93,29 +97,36 @@
<call target="build.opencover" />
</target>

<target name="fetch.solution.packages" description="pull solution nuget packages">
<target name="nuget.restore.solution" description="pull solution nuget packages">
<exec program="${nuget.exe}">
<arg value='restore "${solution.folder}/.nuget/packages.config" -packagesdirectory "${solution.folder}/packages"' />
</exec>
</target>

<target name="build.opencover" depends="fetch.solution.packages">

<exec program="${msbuild.exe}">
<arg value="${solution.folder}/opencover.sln" />
<arg value="/t:Clean,Rebuild" />
<arg value="/p:Configuration=${configuration},Platform=${platform}" />
</exec>

<target name="dotnet.restore.solution" description="restore solution packages">
<exec program="${dotnet.exe}">
<arg value="restore" />
<arg value="${solution.folder}" />
</exec>
</target>

<target name="build.opencover" depends="nuget.restore.solution, dotnet.restore.solution">

<exec program="${msbuild.exe}">
<arg value="${solution.folder}/opencover.sln" />
<arg value="/t:Clean,Rebuild" />
<arg value="/p:Configuration=${configuration},Platform=${platform}" />
</exec>

<property name="expected.output" value="${solution.folder}/bin/${configuration}/OpenCover.Console.exe"/>
<fail unless="${file::exists(expected.output)}">Output file doesn't exist in ${expected.output}</fail>

</target>
<target name="test" description="Run unit tests" >

<target name="test" description="Run unit tests">

<echo message="test: ${solution.folder}/bin/${configuration}/OpenCover.Test.dll" />
<echo message="test: ${solution.folder}/bin/${configuration}/OpenCover.Test.dll" />

<exec program="${nunit-console}">
<arg value="${solution.folder}/bin/${configuration}/OpenCover.Test.dll" />
<arg value="--x86" />
Expand All @@ -126,8 +137,8 @@
</target>

<target name="test-bdd" description="Run BDD tests" >
<echo message="test-bdd: ${solution.folder}/OpenCover.Specs/bin/${configuration}/OpenCover.Specs.dll" />

<echo message="test-bdd: ${solution.folder}/OpenCover.Specs/bin/${configuration}/OpenCover.Specs.dll" />

<exec program="${nunit-console}">
<arg value="${solution.folder}/OpenCover.Specs/bin/${configuration}/OpenCover.Specs.dll" />
Expand All @@ -142,35 +153,35 @@
<target name="test-cpp-internal" description="Run C++ tests" >
<exec program="${open-cover-test-console}" if="${file::exists(open-cover-test-console)}" />
</target>

<target name="unregister" description="Unregister the profiler assembly (per-user)" >
<echo message="unregister: ${solution.folder}/bin/${configuration}/${platform}/OpenCover.Profiler.dll" />
<exec program="regsvr32" >
<exec program="regsvr32" >
<arg value="/u" />
<arg value="/n" />
<arg value="/i:user" />
<arg value="/s" />
<arg value="${solution.folder}/bin/${configuration}/${platform}/OpenCover.Profiler.dll" />
<arg value="${solution.folder}/bin/${configuration}/${platform}/OpenCover.Profiler.dll" />
</exec>
</target>

<target name="register" description="Register the profiler assembly (per-user)" >
<echo message="register: ${solution.folder}/bin/${configuration}/${platform}/OpenCover.Profiler.dll" />
<exec program="regsvr32" >
<echo message="register: ${solution.folder}/bin/${configuration}/${platform}/OpenCover.Profiler.dll" />
<exec program="regsvr32" >
<arg value="/n" />
<arg value="/i:user" />
<arg value="/s" />
<arg value="${solution.folder}/bin/${configuration}/${platform}/OpenCover.Profiler.dll" />
<arg value="${solution.folder}/bin/${configuration}/${platform}/OpenCover.Profiler.dll" />
</exec>
</target>

<target name="dogfood">

<exec program="${solution.folder}/bin/${configuration}/dogfood.cmd"
workingdir="${solution.folder}/bin/${configuration}" />
workingdir="${solution.folder}/bin/${configuration}"/>

<exec program="${solution.folder}/bin/${configuration}/uitest.opencover.cmd"
workingdir="${solution.folder}/bin/${configuration}" />
workingdir="${solution.folder}/bin/${configuration}"/>

<exec program="${coveralls.exe}" workingdir="${solution.folder}/bin/${configuration}">
<arg value="--opencover" />
Expand All @@ -184,10 +195,10 @@
<property name="configuration" value="release" />

<exec program="${solution.folder}/bin/${configuration}/dogfood_exattr.cmd"
workingdir="${solution.folder}/bin/${configuration}" />
workingdir="${solution.folder}/bin/${configuration}"/>

<exec program="${solution.folder}/bin/${configuration}/uitest.opencover.cmd"
workingdir="${solution.folder}/bin/${configuration}" />
workingdir="${solution.folder}/bin/${configuration}"/>

<exec program="${coveralls.exe}" workingdir="${solution.folder}/bin/${configuration}">
<arg value="--opencover" />
Expand Down
Binary file modified main/.nuget/NuGet.exe
Binary file not shown.
24 changes: 6 additions & 18 deletions main/OpenCover.3rdParty.Signer/CrashReporterSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,8 @@ internal static class CrashReporterSigner

public static bool AlreadySigned(string baseFolder)
{
var frameworkAssembly = Path.Combine(baseFolder, TargetFolder, "CrashReporter.NET.dll");
if (File.Exists(frameworkAssembly))
{
try
{
var frameworkDefinition = AssemblyDefinition.ReadAssembly(frameworkAssembly);
return frameworkDefinition.Name.HasPublicKey;
}
catch
{
return false;
}
}
return false;
var crashReporterAssembly = Path.Combine(baseFolder, TargetFolder, "CrashReporter.NET.dll");
return crashReporterAssembly.AlreadySigned();
}

public static void SignAssembly(string baseFolder)
Expand All @@ -42,10 +30,10 @@ public static void SignAssembly(string baseFolder)
assembly = Path.GetFullPath(assembly);
newAssembly = Path.GetFullPath(newAssembly);

File.Copy(assembly, newAssembly, true);
var definition = AssemblyDefinition.ReadAssembly(newAssembly);

definition.SignFile(newAssembly, key);
using (var definition = AssemblyDefinition.ReadAssembly(assembly))
{
definition.SignFile(newAssembly, key);
}
}
}
}
89 changes: 48 additions & 41 deletions main/OpenCover.3rdParty.Signer/GendarmeSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,70 +19,77 @@ internal static class GendarmeSigner
public static bool AlreadySigned(string baseFolder)
{
var frameworkAssembly = Path.Combine(baseFolder, TargetFolder, "Gendarme.Framework.dll");
if (File.Exists(frameworkAssembly))
return frameworkAssembly.AlreadySigned();
}

public static void SignGendarmeRulesMaintainability(string baseFolder)
{
var frameworkAssembly = Path.Combine(baseFolder, TargetFolder, "Gendarme.Framework.dll");
using (var frameworkDefinition = AssemblyDefinition.ReadAssembly(frameworkAssembly))
{
try
{
var frameworkDefinition = AssemblyDefinition.ReadAssembly(frameworkAssembly);
return frameworkDefinition.Name.HasPublicKey;
}
catch
var key = Path.Combine(baseFolder, StrongNameKey);
var assembly = Path.Combine(baseFolder, SourceFolder, "Gendarme.Rules.Maintainability.dll");
var newAssembly = Path.Combine(baseFolder, TargetFolder, "Gendarme.Rules.Maintainability.dll");

assembly = Path.GetFullPath(assembly);
newAssembly = Path.GetFullPath(newAssembly);

File.Copy(assembly, newAssembly, true);
using (var definition = AssemblyDefinition.ReadAssembly(assembly))
{
return false;
BindAssemblyReference(definition, frameworkDefinition);
RebindMonoCecil(definition);
definition.SignFile(newAssembly, key);
}
}
return false;
}

public static void SignGendarmeRulesMaintainability(string baseFolder)
public static void SignGendarmeFramework(string baseFolder)
{
var frameworkAssembly = Path.Combine(baseFolder, TargetFolder, "Gendarme.Framework.dll");
var frameworkDefinition = AssemblyDefinition.ReadAssembly(frameworkAssembly);
var frameworkAssemblyRef = AssemblyNameReference.Parse(frameworkDefinition.Name.ToString());

var key = Path.Combine(baseFolder, StrongNameKey);
var assembly = Path.Combine(baseFolder, SourceFolder, "Gendarme.Rules.Maintainability.dll");
var newAssembly = Path.Combine(baseFolder, TargetFolder, "Gendarme.Rules.Maintainability.dll");
var assembly = Path.Combine(baseFolder, SourceFolder, "Gendarme.Framework.dll");
var newAssembly = Path.Combine(baseFolder, TargetFolder, "Gendarme.Framework.dll");

assembly = Path.GetFullPath(assembly);
newAssembly = Path.GetFullPath(newAssembly);

File.Copy(assembly, newAssembly, true);
var definition = AssemblyDefinition.ReadAssembly(newAssembly);

// update all type references to the now signed base assembly
foreach (var typeReference in definition.MainModule.GetTypeReferences())
using (var definition = AssemblyDefinition.ReadAssembly(assembly, new ReaderParameters { ReadWrite = true }))
{
if (typeReference.Scope.Name == frameworkDefinition.Name.Name)
{
typeReference.Scope = frameworkAssemblyRef;
}
RebindMonoCecil(definition);
definition.SignFile(newAssembly, key);
}
}

// update assembly references to use the now signed base assembly
var oldReference = definition.MainModule.AssemblyReferences.FirstOrDefault(x => x.Name == frameworkDefinition.Name.Name);
if (oldReference != null)
private static void RebindMonoCecil(AssemblyDefinition definition)
{
var assembly = typeof(AssemblyDefinition).Assembly.Location;
using (var monoCecilDefinition = AssemblyDefinition.ReadAssembly(assembly))
{
definition.MainModule.AssemblyReferences.Remove(oldReference);
definition.MainModule.AssemblyReferences.Add(frameworkAssemblyRef);
BindAssemblyReference(definition, monoCecilDefinition);
}

definition.SignFile(newAssembly, key);
}

public static void SignGendarmeFramework(string baseFolder)
private static void BindAssemblyReference(AssemblyDefinition sourceAssembly, AssemblyDefinition referenceAssembly)
{
var key = Path.Combine(baseFolder, StrongNameKey);
var assembly = Path.Combine(baseFolder, SourceFolder, "Gendarme.Framework.dll");
var newAssembly = Path.Combine(baseFolder, TargetFolder, "Gendarme.Framework.dll");
var referenceAssemblyRef = AssemblyNameReference.Parse(referenceAssembly.Name.ToString());

assembly = Path.GetFullPath(assembly);
newAssembly = Path.GetFullPath(newAssembly);
foreach (var typeReference in sourceAssembly.MainModule.GetTypeReferences())
{
if (typeReference.Scope.Name == referenceAssembly.Name.Name)
{
typeReference.Scope = referenceAssemblyRef;
}
}

File.Copy(assembly, newAssembly, true);
var definition = AssemblyDefinition.ReadAssembly(newAssembly);
var oldReference = sourceAssembly
.MainModule.AssemblyReferences
.FirstOrDefault(x => x.Name == referenceAssembly.Name.Name);

definition.SignFile(newAssembly, key);
if (oldReference != null)
{
sourceAssembly.MainModule.AssemblyReferences.Remove(oldReference);
sourceAssembly.MainModule.AssemblyReferences.Add(referenceAssemblyRef);
}
}
}
}
Loading

0 comments on commit 3273476

Please sign in to comment.