Open glararan opened 4 years ago
Could you attach your application's publish logs: https://github.com/dotnet/aspnetcore/wiki/MSBuild-logging?
@pranavkm
Did dotnet build /bl
Logs (excluded build warnings):
F:\ASP.NET Core\Project\src>dotnet build /bl
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files\dotnet\sdk\3.1.201\MSBuild.dll -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\3.1.201\dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\3.1.201\dotnet.dll -maxcpucount -restore -verbosity:m /bl .\Project.csproj
Restore completed in 997,63 ms for F:\ASP.NET Core\Project\src\Project.csproj.
CSC : warning CS8034: Unable to load Analyzer assembly C:\Users\glara\.nuget\packages\microsoft.aspnetcore.components.analyzers\3.1.2\analyzers\dotnet\cs\Microsoft.AspNetCore.Components.Analyzers.dll : Assembly with same name is already loaded [F:\ASP.NET Core\Project\src\Project.csproj]
Project -> F:\_build\Project\blazor\Debug\netcoreapp3.1\Project.dll
Project -> F:\_build\Project\blazor\Debug\netcoreapp3.1\Project.Views.dll
Build succeeded.
This was completed in few secs
Do you mind attaching the build log? It should be a file named msbuild.binlog
that was vreated in the F:\_build\Project\blazor
folder.
@pranavkm oh sorry, my mistake, first time using this.
No worries. Would you mind attaching the logs for the publish command: dotnet publish -p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml /bl
? Nothing in the build log seems particularly problematic, and as you noted it finished fairly quickly.
Slightly unrelated, you could consider adding an explicit reference to the 3.1.3 version of Microsoft.AspNetCore.Components
. This should address the build warning that you're seing:
CSC : warning CS8034: Unable to load Analyzer assembly C:\Users\glara.nuget\packages\microsoft.aspnetcore.components.analyzers\3.1.2\analyzers\dotnet\cs\Microsoft.AspNetCore.Components.Analyzers.dll : Assembly with same name is already loaded [F:\ASP.NET Core\Project\src\Project.csproj]
@pranavkm attachment below. Ok will add msbuild.zip
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>
@pranavkm this sounds very good.. 11 secs. Awesome!
This way it should copy only once from wwwroot and then check for newest right? Mainly asking about css/js files :)
@pranavkm Dunno how this can affect local debug but it happens. I have to remove some line because Blazor dont like it.
InvalidOperationException: Cannot find the fallback endpoint specified by route values: { page: /_Host, area: }.
Sorry, you probably want these too in the ItemGroup
:
<Content Include="**\*.cshtml" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" />
<Content Include="**\*.razor" ExcludeFromSingleFile="true" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" />
<None Remove="**\*.cshtml" />
<None Remove="**\*.razor" />
That said, I'll move this to appropriate repo for tracking
@vijayrkn looks like Target Name=_IncludePrePublishGeneratedContent
is taking up about 4 mins to run in this project.
Sorry, you probably want these too in the
ItemGroup
:<Content Include="**\*.cshtml" ExcludeFromSingleFile="true" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" /> <Content Include="**\*.razor" ExcludeFromSingleFile="true" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" /> <None Remove="**\*.cshtml" /> <None Remove="**\*.razor" />
That said, I'll move this to appropriate repo for tracking
Looks good
@vijayrkn looks like
Target Name=_IncludePrePublishGeneratedContent
is taking up about 4 mins to run in this project.
This was added to account for the files that gets added after the publish process is initiated (like from npm etc). Not sure why it takes that long though. How many files are we talking about in the wwwroot folder?
@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
I can confirm I'm having this issue as well, however, way more severe, an hour+ and MSBuild using 10-20GB/32GB of RAM to do a reactjs publish (net 7 web api project). Applied these csproj changes and it went from an hour+ down to 30sec
I am using following command
dotnet publish -p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml -v:d
then it hangs since1: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