Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Added NetStandard and Upgraded solution. #42

Merged
merged 8 commits into from
Jul 29, 2017
Merged

Conversation

dazinator
Copy link
Member

@dazinator dazinator commented Jul 3, 2017

Fixes #40

Changes proposed in this pull request:

  • Converted from project per target, to a single vs2017 project that targets multiple: net40, net45 and NETStandard
  • AppVeyor.yml changed to use vs2017 build image, and msbuild /t:Pack instead of nuget pack.
  • Compiler directives to:
    • NETStandard build consumes libgit2sharp.portable package instead of normal one.
    • NETStandard build does not have DumpGraph API due to lack of System.Diagnostics.Process API's. DumpGraph is still available for the net40 and net45 targets.
    • NETStandard uses a polyfill for the serializable attribute depends on System.Runtime.Serialization.Formatters package for [Serialzable] attribute. (Had discovered using a polyfill is a bad idea due to netcore not supporting extern alias)
    • NETStandard - Serialization constructors where removed on exceptions as not required.
  • JetBrains annotations package was upgraded.
  • Tests project upgraded to new csproj format.
  • Travis build updated to run under netcore on linux trusty distro, as opposed to mono. (Issue with NUnit adaptor when run under netcoreapp though means tests aren't executed)
  • Temporary version of GitTools.Testing nuget package that I uploaded to nuget myself is being used. Because looks like latest build of GitTools.Testing hasn't incremented the nuget package version or published it, so I did this manually as I don't have access to fix the build for GitTools.Testing.

Open a command line and dotnet build to see the result.

@dazinator
Copy link
Member Author

@dazinator
Copy link
Member Author

dazinator commented Jul 8, 2017

So exceptions don't need to be serializable in netcore because netcore doesn't support AppDomain's. However the other TfM's do. MS have provided a nuget package for netstandard that makes the [Serializable] attribute available - just so that your code can still compile for those targeting multiple frameworks. The problem with creating your own polyfill for this attribute is that if multiple libraries each create a polyfill of this attribute, under .netcore - which doesn't support the ability to alias references, you end up with conflicts due to the attribute existing multiple times. Therefore it's best if any library needs the attribute, to all agree on using the attribute from here: https://www.nuget.org/packages/System.Runtime.Serialization.Formatters/

Or - wrap all uses of it in compiler directives so it's not used at all in netstandard / netcore builds.

@dazinator
Copy link
Member Author

dazinator commented Jul 8, 2017

Ok now it's just the Travis build that needs fixing

@dazinator
Copy link
Member Author

I'm not familiar with Travis - can I ask that someone else help with fixing the travis build? Just need to get it building under latest msbuild (or dotnet cli which is what i attempted) but it seems the travis image doesn't support dotnet cli - it looks like a linux image..

@jarrodldavis
Copy link

You need to update the .travis.yml file to specify the Ubuntu distribution to build on (trusty). Here's more information about .NET Core on Travis CI.

@dazinator
Copy link
Member Author

dazinator commented Jul 9, 2017

@jarrodldavis - Thanks for that, I have switched to trusty. It now complains when doing a dotnet build that it can't find the net framework reference assemblies:

mon.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/home/travis/build/GitTools/GitTools.Core/src/GitTools.Core.Tests/GitTools.Core.Tests.csproj]

@dazinator
Copy link
Member Author

I'm going to convert the tests project to run under dotnet cli instead. (https://stackoverflow.com/questions/36578232/run-nunit-tests-in-dotnet-core)

@dazinator
Copy link
Member Author

dazinator commented Jul 9, 2017

I think we probably need to run the tests on travis under netcoreapp as it seems the full desktop versions of framework aren't available (unless you build under mono / xbuild which doesn't support the new csproj format).

I'm much prefering the AppVeyor experience so far.

@dazinator
Copy link
Member Author

Waiting on GitTools/GitTools.Testing#6 to be merged, so can then get the tests on travis to run under netcoreapp.

@dazinator
Copy link
Member Author

dazinator commented Jul 28, 2017

Running nunit tests like this (under netcoreapp1.1) with the latest nunit adapator:

 dotnet test "GitTools.Core.Tests.csproj"  --framework netcoreapp1.1

exhibits this: nunit/nunit3-vs-adapter#325

Therefore I am multi-targeting the tests project for net46 and netcoreapp1.1 - so that in VS we can still see and run the tests in test explorer under net461. Travis which uses netcoreapp1.1 won;t be able to get test results until this nunit adaptor issus is fixed.

@dazinator dazinator force-pushed the feature/netstandard branch from 73756b7 to 5b60228 Compare July 28, 2017 15:51
@dazinator
Copy link
Member Author

dazinator commented Jul 28, 2017

It seems many of the shouldly tests fail on linux under netcoreapp1.1 - assertions fail like:

Shouldly.ShouldAssertException : "/tmp/_3/.git/"
    should be
"/tmp/.git\"

I can see that many of them have previously been excluded from running under mono so assume they were failing with the same issue.

https://travis-ci.org/GitTools/GitTools.Core/builds/258618089?utm_source=github_status&utm_medium=notification

For now, I am going to exclude them as before, but they should probably be fixed up properly so that they pass (seperate bit of work)

@dazinator
Copy link
Member Author

WARNING: I am going to merge this tomorrow.

@dazinator
Copy link
Member Author

Ok I am merging..

@dazinator dazinator merged commit 8dbab2c into master Jul 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port to NETStandard
3 participants