sdk icon indicating copy to clipboard operation
sdk copied to clipboard

publish command not copying wwwroot files on first run

Open ckuyehar opened this issue 9 years ago • 7 comments

Steps to reproduce

  1. Clone project from github repo: https://github.com/ckuyehar/dotnet-mvc-bug
  2. dotnet restore
  3. dotnet publish

Expected behavior

The first time I run dotnet publish, I expected the assets folder to be copied to the published wwwroot folder.

Actual behavior

The first time I run dotnet publish, the published wwwroot folder (ie, bin\Debug\netcoreapp1.1\publish\wwwroot) is missing the assets folder .

After running dotnet publish for the first time, if you make changes to the file a.txt contained in the .\assets folder and run dotnet publish again the published wwwroot folder will always contain the latest changes made to the file a.txt.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.3)

Product Information: Version: 1.0.3 Commit SHA-1 hash: 37224c9917

Runtime Environment: OS Name: Windows OS Version: 10.0.14393 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.3

ckuyehar avatar Apr 26 '17 01:04 ckuyehar

I was just informed that this was caused by my incorrect understanding of msbuild.

You may close.

ckuyehar avatar Apr 26 '17 23:04 ckuyehar

What was your misunderstanding? It may be valuable to other people who come across a similar issue.

livarcocc avatar May 05 '17 05:05 livarcocc

@ckuyehar I'm having a similar issue - what was your misunderstanding?

AlexanderLea avatar May 23 '17 07:05 AlexanderLea

I misunderstood how msbuild works. I assumed msbuild would understand what files to include after a task. Sadly it doesn't.

So say you clone the repo I mentioned above and then performed a dotnet restore. When you execute dotnet publish it performs a build and then a publish. When the publish target runs somewhere in the pipeline it calls another target called _CopyResolvedFilesToPublishPreserveNewest. That target doesn't know about the new file (in wwwroot) so as a result it doesn't copy it over to the publish folder.

So the solution? dotnet build and then dotnet publish.

VAchris avatar May 23 '17 09:05 VAchris

Looks like a duplicate of https://github.com/aspnet/websdk/issues/114

There is a fix in the web sdk now that re-scans the glob patterns before publish but i don't know if this is going to be included in 1.1 or 2.0 CLIs..

dasMulli avatar May 23 '17 09:05 dasMulli

Thank you both!

For the time being, I've implemented a workaround documented here https://github.com/dotnet/cli/issues/5498#issuecomment-275932671.

AlexanderLea avatar May 23 '17 09:05 AlexanderLea

Who still has similar issue try to read my comment

t0xicDen avatar Sep 13 '17 08:09 t0xicDen