Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net core 2.0 publish generating lots off DLL

A programming one application few months and everytime when i published my project, tis generated 19 items (without wwwroot files). And from today, its generating 202 files with lots of .dll (without wwwroot files). I have no idea what happend or what i did. My application using .NET Core 2.0. I dont know what information about my project is relevant. Aproximately 81/202 files are only Microsoft.AspNetCore libraries and 43/202 are only Microsoft.Extensions libraries. I tried deleted obj, bin, properties and node_modules and still same problem. After upload only files what its generated before from lots of files, everything worked. I think its not necessary .dll but i have no idea why asp.net still generating them. Thank you for any advice.

EDIT:

Here is one big screenshot of publish output, dependencies and output of publish added by request from one of users who commented this question: enter image description here

EDIT:

I got new error after change publish properties from Self-contained deployments to Framework-dependent deployments and i get new error from output:

C:\Program Files\dotnet\sdk\2.1.400-preview-009063\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(125,5): Error NETSDK1068: The framework-dependent application host requires a target framework of at least 'netcoreapp2.1'.

EDIT:

Now i tried create new project asp.net core 2.0 and tried published. Same problem. Something is wrong with my sdk or i dont know.

SOLUTION:

I created new project with target 2.1 and move all source files. After resolve few error everything working fine.

like image 727
Frantisek Pastorek Avatar asked Jul 24 '18 15:07

Frantisek Pastorek


People also ask

How do I publish an entire solution in Visual Studio?

To publish from Visual Studio, do the following: Change the solution configuration from Debug to Release on the toolbar to build a Release (rather than a Debug) version of your app. Right-click on the project (not the solution) in Solution Explorer and select Publish. In the Publish tab, select Publish.

What does .NET core publish do?

dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory. The output includes the following assets: Intermediate Language (IL) code in an assembly with a dll extension.


2 Answers

This is caused by a bug introduced in .NET Core SDK version 2.1.400. See Framework Dependent Publish doesn't work on 2.1.400 #9852

There is a workaround - publish via the command line and pass the arg --self-contained false.

Example:

dotnet publish -f netcoreapp2.0 -c Release --self-contained false

like image 82
SausageFingers Avatar answered Oct 31 '22 15:10

SausageFingers


On Visual Studio 15.8.2 I too had this problem. Unfortunately I could not simply upgrade the application because we have runtime version restrictions on the internally managed deployed servers. So even though I can build on the latest SDK version (2.1.401), where the application is deployed has an older SDK version (2.1.100).

The SDK and Runtime version correlations for .NET Core 2.0 can be found here.

My problem manifested thusly: The Build and Rebuild succeeded, but the Publish failed with the error message Error NETSDK1068: The framework-dependent application host requires a target framework of at least 'netcoreapp2.1'. I learned from here that the default is to use the latest installed version.

Starting with .NET Core 2.0, the following rules apply when determining which version of the SDK to use:

  • If no global.json file is found or global.json doesn't specify an SDK version, the latest installed SDK version is used. Latest SDK version can be either release or pre-release - the highest version number wins. (emphasis added)

In this same article, I learned to make use of the global.json file to address this error. I used git-bash and cd'd to the local working directory for the web application I was trying to publish. The corresponding csproj file should be in this directory. From here I ran the following:

dotnet new globaljson --sdk-version 2.1.100

Now I can use the following publish configure settings: - Configuration: Release - Target Framework: netcoreapp2.0 - Deployment Mode: Framework-Dependent - Target Runtime: Portable

like image 45
gregsonian Avatar answered Oct 31 '22 16:10

gregsonian