mardi 26 mars 2019

How to set up .deps file

I'm quite new to .NET Core so this may be a newbie question.

I'm setting up a build pipeline on GitLab for a .NET Core Console app which uses some tests and has a dependency on System.Text.Encoding.CodePages.dll. The app only consists of one .csproj at the moment.

My pipeline has two jobs, one to build the app and one to run the tests. Both are executed within a docker on a windows server 2019. In detail it goes like this:

  1. First job builds the app.
  2. First job copies all .dlls as well as into the artifacts folder of GitLab.
  3. Second job runs vstest against the projects dll.

Step 1+2 work like a charm. However, if i try to run the tests I get an error:

Testhost process exited with error: Error: An assembly specified in the application dependencies manifest (Buhler.IoT.Integration.PerformanceTests.deps.json) was not found: package: 'System.Text.Encoding.CodePages', version: '4.6.0-preview.19073.11' path: 'runtimes/win/lib/netcoreapp2.0/System.Text.Encoding.CodePages.dll'

I figured out that .NET Core dependencies are stored in a file called <myproject>.deps where there is a line saying:

 "System.Text.Encoding.CodePages/4.6.0-preview.19073.11": {
    "dependencies": {
      "Microsoft.NETCore.Platforms": "3.0.0-preview.19073.11",
      "System.Runtime.CompilerServices.Unsafe": "4.6.0-preview.19073.11"
    },
    "runtime": {
      "lib/netstandard2.0/System.Text.Encoding.CodePages.dll": {
        "assemblyVersion": "4.1.2.0",
        "fileVersion": "4.7.19.7311"
      }
    },
    "runtimeTargets": {
      "runtimes/win/lib/netcoreapp2.0/System.Text.Encoding.CodePages.dll": {
        "rid": "win",
        "assetType": "runtime",
        "assemblyVersion": "4.1.2.0",
        "fileVersion": "4.7.19.7311"
      }
    }
  }

So the path is pointing to a runtimes/win/lib/netcoreapp2.0/ folder structure which of course doesn't exist on the runner. The System.Text.Encoding.CodePages.dll however does exist but lies in the root path of the app (so the same path as the <myproject>.prep).

My question therefore is:

How and where can i configure how the .prep gets generated? Or is there a way to keep structure from nuget by copying files? At the moment I just use this in my .csproj file:

<PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

Aucun commentaire:

Enregistrer un commentaire