Compiling .Net Core VS17

Over the past few days, I have been trying to compile my .net console application and download it in vps from "Windows Server 2012 R2". The reason I use .Net Core because it is necessary for the library is Discord.Net 1.0.

The first thing I tried was just to take my dll and release data with the following file structure:

LeveledStudios.deps
LeveledStudios.dll
LeveledStudios.pdb
LeveledStudios.runtimeconfig.dev
LeveledStdios.runtimeconfig

This worked fine for execution on the PC on which I developed it, however then I went to my server, launched "dotnet LeveledStudios.dll" and encountered an error

Error: assembly specified in the dependencies manifest was not found -- package: 'discord.net.commands', version '1.0.0-rc-00546', path: 'lib/netstandard1.3/Discord.Net.Commands.dll`

Noting that this set the structure of the .nuget folder on my development computer, I copied it and ran into the same problem and tried to copy it to the same folder as leveledstudios.dll, only to run in a .dll that refused to work. It also includes missing system DLLs such as System.Net.Http, etc.

I did a few searches and saw information about standalone .net applications. That sounds great, because obviously my problem was that it did not compile with all my additional libraries. I was a bit confused because I did not have a project.json file as indicated in all the documentation I read on it.

However, at startup:

dotnet restore
dotnet build -r win10-x64

I get a lot of errors, assuming that none of the system libraries compiled:

Mistakes

Contents of LeveledStudios.csproj:

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Discord.Net" Version="1.0.0-rc-00546" />
    <PackageReference Include="Discord.Net.Commands" Version="1.0.0-rc-00546" />
    <PackageReference Include="Discord.Net.Core" Version="1.0.0-rc-00546" />
    <PackageReference Include="Discord.Net.WebSocket" Version="1.0.0-rc-00546" />
    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
    <PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta2" />
  </ItemGroup>
</Project>

- .Net - , .

+4
1

... . [sound] perfect... ... , , .

, happeed , *.csproj:

<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>

Restore , .

dotnet restore
dotnet build -r win10-x64
dotnet publish -c release -r win10-x64

*.csproj :

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
  <PropertyGroup>
    <OutputType>exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="**\*.cs" />
    <EmbeddedResource Include="**\*.resx" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Discord.Net" Version="1.0.0-rc-00546" />
    <PackageReference Include="Discord.Net.Commands" Version="1.0.0-rc-00546" />
    <PackageReference Include="Discord.Net.Core" Version="1.0.0-rc-00546" />
    <PackageReference Include="Discord.Net.WebSocket" Version="1.0.0-rc-00546" />
    <PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
    <PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta2" />
  </ItemGroup>
</Project>

, .

( , , ) , , RuntimeIdentifiers. , .

dotnet restore
dotnet build
dotnet publish

, Discord, :

bin\Debug\netcoreapp1.0\publish
+1

Source: https://habr.com/ru/post/1667462/


All Articles