netstandard project not building

Kent's Avatar

Kent

Aug 18, 2016 @ 10:32 AM

Hi,

I have a project that builds perfectly fine on my dev machine, but not on AppVeyor. It's targeting netstandard 1.0, and that would appear to be the problem.

I assume the VS2015 image includes update 3? Any thoughts on what might be causing this failure?

Thanks,
Kent

  1. 1 Posted by Ilya Finkelshte... on Aug 18, 2016 @ 08:19 PM

    Ilya Finkelshteyn's Avatar

    Hi Kent,

    Running nuget restore before your build.bat enabled the build. I think that it was Microsoft.NETCore.Portable.Compatibility which was missing.

    However some tests are failing because of some issue with new line character (build of my fork - https://ci.appveyor.com/project/IlyaFinkelshteyn/kbcsv/build/1.0.5)

      **Expected: one,two,three\nfour,five,six\nseven,eight,nine,ten\n**
      **Actual:   one,two,three\r\nfour,five,six\r\nseven,eight,nine,ten\r\n
    

    It does not fail on my machine though. And obviously on your machine ☺

    I attached debugger on both build VM and my machine to write_records_async_writes_records_to_text_writer() and here are data from immediate window (breakpoint is on Assert.Equal() statement). On immediate window I am looking onto objects using inside Assert.Equal() statement.

    Build VM:

    stringWriter
    {one,two,three
    four,five,six
    seven,eight,nine,ten
    }
        CoreNewLine: {char[2]}
        Encoding: {System.Text.UnicodeEncoding}
        FormatProvider: {en-US}
        NewLine: "\r\n"
    expectedCsv
    "one,two,three\nfour,five,six\nseven,eight,nine,ten\n"
    

    My computer:

    stringWriter
    {one,two,three
    four,five,six
    seven,eight,nine,ten
    }
        CoreNewLine: {char[2]}
        Encoding: {System.Text.UnicodeEncoding}
        FormatProvider: {en-US}
        Identity: null
        InternalFormatProvider: {en-US}
        NewLine: "\r\n"
        __identity: null
        _isOpen: false
        _sb: {one,two,three
    four,five,six
    seven,eight,nine,ten
    }
    expectedCsv
    "one,two,three\r\nfour,five,six\r\nseven,eight,nine,ten\r\n"
    

    As you see stringWriter instance has more members on my computer, and expectedCsv has \r\n as a new line on my computer.

    Something is fundamentally missing on build VM. I will try to understand, but you are obviously more familiar with this solution – do you have an idea what can be wrong?

    --ilya.

  2. 2 Posted by Ilya Finkelshte... on Aug 18, 2016 @ 09:13 PM

    Ilya Finkelshteyn's Avatar

    OK, my co-worker advised me to try git config --global core.autocrlf true at init stage (before git clone) and it works now. Here is working YAML:

    version: 1.0.{build}
    init:
    - cmd: git config --global core.autocrlf true
    install:
    - ps: nuget restore
    build_script:
    - cmd: build.bat
    test: off
    

    --ilya.

  3. 3 Posted by Kent on Aug 20, 2016 @ 05:47 AM

    Kent's Avatar

    That's super helpful - thanks Ilya!

    The missing dependency kinda makes sense. My build script restores all packages in packages.config files, but I switched to netstandard so am using project.json now. Will have to see whether FAKE supports restoring packages from project.json files...

    Cheers,
    Kent

  4. 4 Posted by antao.almada on Dec 02, 2016 @ 06:22 PM

    antao.almada's Avatar

    Hi,
    I converted my project from PCL to netstandard and I also can't make it build here.
    I already added the nuget restore to my init.
    The project is at https://ci.appveyor.com/project/AntaoAlmada/netfabric-angle
    Thanks,
    Antao

  5. 5 Posted by Ilya Finkelshte... on Dec 05, 2016 @ 06:45 PM

    Ilya Finkelshteyn's Avatar

    @Antao can you please share your configuration in YAML format. This way we can reproduce you issue and help. You can use Settings > Export YAML for this.

    --ilya.

  6. 6 Posted by antao.almada on Dec 14, 2016 @ 05:51 PM

    antao.almada's Avatar

    @ilya Here is the configuration. Thanks

  7. 7 Posted by Ilya Finkelshte... on Dec 15, 2016 @ 07:59 AM

    Ilya Finkelshteyn's Avatar

    Hi Antao,

    I wonder if it builds for you locally? For me it started building only if I reverted those this and this line...

    --ilya.

  8. 8 Posted by antao.almada on Jan 07, 2017 @ 10:07 PM

    antao.almada's Avatar

    Hi Ilya,
    I'm using VS 2017 RC. Can that be an issue?
    Antao

  9. 9 Posted by Ilya Finkelshte... on Jan 08, 2017 @ 03:39 AM

    Ilya Finkelshteyn's Avatar

    Lets verify this theory. Can you please ask to enable experimental VS 2017 build worker image here and try?

    --ilya.

  10. 10 Posted by antao.almada on Jan 23, 2017 @ 09:50 AM

    antao.almada's Avatar

    Hi Ilya,
    While working on an unrelated project I run into the same issue and I think I now know its source. When using project.json, MSBuild requires a Microsoft.NuGet.targets extension to get the references to the NuGet packages. This MSBuild extension is located at C:\Program Files (x86)\MSBuild\Microsoft\NuGet and it's imported by C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.Targets\ImportAfter\Microsoft.NuGet.ImportAfter.targets. These seem to be installed by Visual Studio, not by the framework or NuGet.
    This extension is automatically imported by the two last lines of C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets. Notice that it looks for extensions in $(MSBuildExtensionsPath) and $(MSBuildUserExtensionsPath), so I tried a workaround. I added the extension files to my repository and created a MSBuildUserExtensionsPath environment variable pointing to it. Unfortunately it's still not working.
    I can't make it work in TeamCity either: https://teamcity-support.jetbrains.com/hc/en-us/community/posts/115...

  11. 11 Posted by antao.almada on Jan 23, 2017 @ 01:29 PM

    antao.almada's Avatar

    I was using the wrong syntax for the MSBuildUserExtensionsPath environment variable. Now that I set it to %APPVEYOR_BUILD_FOLDER%\tools\MSBuild I get the error message:

    C:\projects\netfabric-angle\tools\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Microsoft.NuGet.ImportAfter.targets(6,3): warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets" cannot be imported again. It was already imported at "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Microsoft.NuGet.ImportAfter.targets (16,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\projects\netfabric-angle\NetFabric.Angle\NetFabric.Angle.csproj]

    This means my .targets theory is wrong... :(

  12. 12 Posted by antao.almada on Jan 23, 2017 @ 01:56 PM

    antao.almada's Avatar

    Returning to the previous state, I noticed that ResolveNuGetPackageAssets is always skipped...

    Target "ResolveNuGetPackageAssets" skipped, due to false condition; ('$(ResolveNuGetPackages)' == 'true' and exists('$(ProjectLockFile)')) was evaluated as ('true' == 'true' and exists('project.lock.json')).

  13. 13 Posted by Ilya Finkelshte... on Jan 28, 2017 @ 01:08 AM

    Ilya Finkelshteyn's Avatar

    Could you please provide with instructions/steps you followed to covert from PCL to netstandard? Also does it builds for you locally? And if yes, does it builds with VS or also with msbuild command?

  14. Ilya Finkelshteyn closed this discussion on Aug 25, 2018 @ 02:14 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac