question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet publish takes too long, about 5 minutes

See original GitHub issue

I am using following command dotnet publish -p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml -v:d then it hangs since 1:7>Done building target "_RazorGetCopyToPublishDirectoryItems" in project "project.csproj".

Other projects publish so quick. I removed all not necessary folders from project.

Time Elapsed 00:04:48.26

Further technical details

  • ASP.NET Core version 3.1.3
  • IDE VS 16.5

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pranavkmcommented, May 1, 2020

Your project has a fair number of “Content” files and it appears this one target that’s inspecting them might be taking way too long.

Could you try an experiment to see if it helps? To your project file add:

<PropertyGroup>
  <EnableDefaultContentItems>false</EnableDefaultContentItems>
</PropertyGroup>

 <ItemGroup>
    <!-- Publish everything under wwwroot, all JSON files, all config files and all Razor files -->
    <Content Include="wwwroot\**" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
    <Content Include="**\*.config" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" />
    <Content Include="**\*.json" ExcludeFromSingleFile="true" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" />

    <!-- Set CopyToPublishDirectory to Never for items under AppDesignerFolder ("Properties", by default) to avoid publishing launchSettings.json -->
    <Content Update="$(AppDesignerFolder)\**" CopyToPublishDirectory="Never" Condition="'$(AppDesignerFolder)' != ''"/>   

    <!-- Remove Content items from other item types (in a way that CPS understands) -->
    <None Remove="wwwroot\**;**\*.json;**\*.config" />
    <Compile Remove="wwwroot\**" />
    <EmbeddedResource Remove="wwwroot\**" />
</ItemGroup>
0reactions
glararancommented, May 3, 2020

@vijayrkn 68.272 Files, 273 Folders but I have following in csproj

    <Compile Remove="Themes\**" />
    <Content Remove="Themes\**" />
    <Content Remove="wwwroot\uploads\**" />
    <EmbeddedResource Remove="Themes\**" />
    <EmbeddedResource Remove="wwwroot\uploads\**" />
    <None Remove="Themes\**" />
    <None Remove="wwwroot\uploads\**" />

This should remove it from project and also from publishing or not? If I dont count Themes & uploads then its totally 2523 files

Read more comments on GitHub >

github_iconTop Results From Across the Web

Net core web application publish take too long
Even it takes more time to run local iis when compare to other .net framework applications. But publish task became painful, since it...
Read more >
aspnet core build slow only when publishing
Publish can take a long time if your App generates temp files and you don't remove these files regularly. Try to check 'Remove...
Read more >
DotNet core slow restore : r/docker
recently I'm facing a increase on the build time (+5 minutes from initial ~1 minute) when doing . There was no major changes...
Read more >
How to Optimize .NET Pipelines in Azure DevOps ... - Tinkerer
If you'll notice our git checkout takes a long time. 2 minutes is an eternity for a checkout. This was due to two...
Read more >
ASP.NET Tutorial | Hello World in 5 minutes
Step-by-step instructions for installing .NET and building your first Hello World web application. Develop with free tools for Linux, macOS, and Windows.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found