dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.75k stars 1.07k forks source link

dotnet publish for sdk 3.x produces different output than sdk 2.x #3700

Open iyhammad opened 5 years ago

iyhammad commented 5 years ago

I've an application the uses .NET Core 2.2 and build against net472. I discovered that publishing the same app using .NET Core SDK 3.x produces different publish output than SDK 2.x. Below are sample of the different output of the 2 SDKs. SDK 2.x SDK 3.x

If this an intended behavior and not a bug, I believe we should warn people to explicitly specify the required SDK for building their application part of their solution using global.json Otherwise, specially if they are building using cloud tools, the system will be published with missing files. If this is bug, I'me ready to share more insights about the application that packages that I'm using to reproduce the bug.

livarcocc commented 5 years ago

What do you mean by it uses netcore 2.2 against net4.7.2? Do you mean you reference asp.net packages directly at version 2.2?

iyhammad commented 5 years ago

I mean we reference .NET Core Packages v2.2.x and our build target is net472. below is a snippet of our csproj file to give you more insights.

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>    
    <TargetFramework>net472</TargetFramework>
    <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
    <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
    <RazorCompileOnBuild>true</RazorCompileOnBuild>
    <ResolvedRazorCompileToolset>RazorSdk</ResolvedRazorCompileToolset>
    <IncludeContentInPack>false</IncludeContentInPack>
    <EnableDefaultContentItems>true</EnableDefaultContentItems>
    <EnableDefaultRazorGenerateItems>true</EnableDefaultRazorGenerateItems>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>        
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Abp.HangFire.AspNetCore" Version="4.8.1" />
    <PackageReference Include="Abp.MailKit" Version="4.8.1" />
    <PackageReference Include="Castle.Core-Serilog" Version="4.4.0" />
    <PackageReference Include="Dawn.Guard" Version="1.9.0" />
    <PackageReference Include="DocumentFormat.OpenXml" Version="2.9.1" />
    <PackageReference Include="Hangfire.SqlServer" Version="1.7.4" />
    <PackageReference Include="IdentityModel" Version="3.10.10" />
    <PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="1.1.16" />
    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.1" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3">
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Castle.LoggingFacility.MsLogging" Version="3.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.2.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="NuGet.Frameworks" Version="5.2.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
    <PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" />
    <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
    <PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0005" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System" />
  </ItemGroup>
  <ItemGroup>
    <None Update="modules\**\*">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>
dasMulli commented 5 years ago

I believe the 3.0 web sdk adds additional analyzers by default..