title: Publish Fails when targeting multiple frameworks in VS2017
body: <p>When targeting multiple frameworks in Visual Studio 2017 project (netcoreapp1.1;net462)</p>
  
  <p>Every time I try to publish the publish fails with the error:</p>
  
  <blockquote>
    <p>"The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, please specify the framework for the published application"</p>
  </blockquote>
  
  <p>I've got my property group conditionals in place, but what else do I need to do to 'specify the framework for the published application'. Am I missing something?</p>
  
  <p>Further - Project compiles fine. Also, worthy of note it was a project created in VS 2015 and converted to a VS 2017 project.</p>
  
  <p>Here is .csproj:</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
    &lt;PropertyGroup&gt;
      &lt;TargetFrameworks&gt;netcoreapp1.1;net462&lt;/TargetFrameworks&gt;
      &lt;PreserveCompilationContext&gt;true&lt;/PreserveCompilationContext&gt;
      &lt;AssemblyName&gt;Project.WebApp&lt;/AssemblyName&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;PackageId&gt;Project.WebApp&lt;/PackageId&gt;
      &lt;RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.1' "&gt;1.1.1&lt;/RuntimeFrameworkVersion&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemGroup&gt;
      &lt;None Include="App.config" /&gt;
      &lt;None Update="wwwroot\**\*"&gt;
        &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
      &lt;/None&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;ProjectReference Include="..\Data\Proj.Data.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Data\Proj.Data.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Web.Client\Proj.Web.Client.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Web.Models\Proj.Web.Models.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Services.Client\Proj.Services.Client.csproj" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="AngleSharp" Version="0.9.9" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="1.0.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup Condition=" '$(TargetFramework)' == 'net462' "&gt;
      &lt;Reference Include="System" /&gt;
      &lt;Reference Include="Microsoft.CSharp" /&gt;
    &lt;/ItemGroup&gt;
    &lt;Target Name="PrepublishScript" BeforeTargets="PrepareForPublish" Condition=" '$(IsCrossTargetingBuild)' != 'true' "&gt;
      &lt;Exec Command="bower install" /&gt;
      &lt;Exec Command="dotnet bundle" /&gt;
    &lt;/Target&gt;
    &lt;ItemGroup&gt;
      &lt;DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" /&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>Also here is the Publish Profile, it appears to specify a Publish Framework:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--
  This file is used by the publish/package process of your Web project. You can customize the behavior of this process
  by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
  --&gt;
  &lt;Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;WebPublishMethod&gt;FileSystem&lt;/WebPublishMethod&gt;
      &lt;LastUsedBuildConfiguration&gt;Debug&lt;/LastUsedBuildConfiguration&gt;
      &lt;LastUsedPlatform&gt;Any CPU&lt;/LastUsedPlatform&gt;
      &lt;SiteUrlToLaunchAfterPublish /&gt;
      &lt;LaunchSiteAfterPublish&gt;True&lt;/LaunchSiteAfterPublish&gt;
      &lt;ExcludeApp_Data&gt;False&lt;/ExcludeApp_Data&gt;
      &lt;PublishFramework&gt;netcoreapp1.1&lt;/PublishFramework&gt;
      &lt;ProjectGuid&gt;3794908a-5af3-4dba-bb6a-8d846b773ff7&lt;/ProjectGuid&gt;
      &lt;publishUrl&gt;\\app\Applications\App\Web Site\&lt;/publishUrl&gt;
      &lt;DeleteExistingFiles&gt;True&lt;/DeleteExistingFiles&gt;
    &lt;/PropertyGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p><strong>EDIT: The solution that worked for me</strong>
  I tried @Stan88 solution of just using the command line and specifying the version to publish. This didn't work for me as my PrepublishScript failed for some reason.</p>
  
  <p>In the end what worked for me was basically editing my .csproj file to only target the netcoreapp1.1 framework. However, in the end I ended up realizing my PrepublishScript had issues and ended up deleting reference to it in the .csproj file - so in the end I think Stan88's command line solution would have worked if not for prepublish craziness, hence, marked as correct.</p>
  
  <p>Here is what my .csproj ended up looking like.</p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
    &lt;PropertyGroup&gt;
      &lt;TargetFrameworks&gt;netcoreapp1.1&lt;/TargetFrameworks&gt;
      &lt;PreserveCompilationContext&gt;true&lt;/PreserveCompilationContext&gt;
      &lt;AssemblyName&gt;Project.WebApp&lt;/AssemblyName&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;PackageId&gt;Project.WebApp&lt;/PackageId&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemGroup&gt;
      &lt;None Include="App.config" /&gt;
      &lt;None Update="wwwroot\**\*"&gt;
        &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
      &lt;/None&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;ProjectReference Include="..\Data\Proj.Data.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Data\Proj.Data.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Web.Client\Proj.Web.Client.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Web.Models\Proj.Web.Models.csproj" /&gt;
      &lt;ProjectReference Include="..\Proj.Services.Client\Proj.Services.Client.csproj" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="AngleSharp" Version="0.9.9" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="1.0.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" /&gt;
      &lt;PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" /&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>