3
votes

EDIT: I've noticed that there's a folder in bin\Debug\net461\Publish with everything required, I tried to check the configuration used this way :

#if DEBUG
        ViewData["Message"] = "DEBUG";
#else
        ViewData["Message"] = "else";
#endif

The web page displays "DEBUG"...

Original question:

ASP.Net core publishes an empty folder : I don't have that problem with ASP.Net, only with ASP.Net Core. So here's how I create my publishing profile on both platforms :

Create profile => Folder => bin\Release\PublishOutput => Create Profile => Publish

With Asp.Net it generates this .pubxml :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"     xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>bin\Release\PublishOutput</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
</Project>

Output with Asp.Net:

2>Web App was published successfully file:///Path/bin/Release/PublishOutput
2>
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

With Asp.Net Core it generates this .pubxml :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <ProjectGuid>32b7ffef-9cf4-471a-ab1a-ec3c69d0dd13</ProjectGuid>
    <publishUrl>bin\Release\PublishOutput</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
</Project>

Output with Asp.Net Core:

Web App was published successfully file:///Path/bin/Release/PublishOutput
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

I tried on 3 computers, I still get an empty folder with Asp.Net Core.

1
This doesn't answer your question directly directly, but solves your problem: use the dotnet CLI when publishing, cd to the directory of your .csproj or .sln, then run dotnet publish -c Release -o "path/to/output" in your favorite terminaldie maus
I forgot to add 'Plz avoid command lines' in my question, but after struggling for hours, your comment is the only solution as for now, could you post your comment as an answer so that I can accept it?Akli
I haven't answered your question, only worked around it. I don't think it deserves to be marked as answer. My advice, when it comes to dotnet core, is to use its CLI. It's actually pretty simple and intuitive. Many modern CLI tools are.die maus
Even if someone finds a solution to this VS bug, Microsoft will fix this and my question will be obsolete in less than a couple of months, just post your comment as an answer.Akli

1 Answers

2
votes

This doesn't answer your question directly, but solves your problem: use the dotnet CLI when publishing, cd to the directory of your .csproj or .sln, then run:

dotnet publish -c Release -o "path/to/output"