In an asp.net project add directories into the PublishOptions Include setting in the project.json.
e.g.
"publishOptions": {
"include": [
"wwwroot",
"app",
"Views",
"appsettings.json",
"web.config"
]
},
Then publish using donet CLI.
e.g.
dotnet publish --framework net46 --output "..\..\..\someRelativeDir" --configuration Debug
The includes folders are copied across to the publish directory.
The expected output is the same as running the command with a full path.
e.g.
dotnet publish --framework net46 --output "c:\temp\myFullPathDir" --configuration Debug
The directories specified in the publishOptions includes are not copied.
dotnet --info output:
.NET Command Line Tools (1.0.0-preview2-003121)
Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
After a little digging, this is what I have found:
It looks like like the IncludesFileResolver currently expects to receive a fully qualified path as a target path. It specifically is checking for this on line 45 of Microsoft.DotNet.ProjectModel.Files.IncludesFileResolver. It looks like PublishProjectContext calling this without resolving the to a full path on line 187 of Microsoft.DotNet.Tools.Publish.PublishCommand.
https://github.com/dotnet/cli/blob/04f40f906dce2678d80fb9787e68de76ee6bf57e/src/Microsoft.DotNet.ProjectModel/Files/IncludeFilesResolver.cs
https://github.com/dotnet/cli/blob/04f40f906dce2678d80fb9787e68de76ee6bf57e/src/dotnet/commands/dotnet-publish/PublishCommand.cs
I am hitting this issue as well... the include files only show up if I use a full path when calling dotnet publish. However, I didn't start seeing the issue until a recent selfhost build upgrade. Are you using preview builds of Windows by any chance?
No, this is on a machine running Server 2012 R2.
Ah, well in that case it isn't likely to be an operating system issue. Thanks for reporting this; knowing it was an issue of full path vs relative path helped me fix our build scripts!
No problem, glad it helped. We did the same with our build scripts. The side affect being that the build must be run from a specific location because the msbuild context will resolve to full paths from this location.
Is there any plan to fix this?
Yep, MSBuild has a much stronger globbing functionality. I'm unable to repro this in preview3. Please re-open if you still see this.
I am still having the same issue.
dotnet publish --configuration Release --output ..published-app
dotnet publish --configuration Release --output D:projectsxpublished-app
But then when I do add the full path it copies everything! (srcClient, srcServer, bin, obj, etc...) This then forces me to use the "publishOptions":{ exclude:[ "with all the above mentioned" ]}
Seems like this should be fixed
I just installed .net Core like a week a go:
.NET Command Line Tools (1.0.0-preview2-003131)
Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40e58
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
I have another reproduction scenario.
This does not work (wwwroot is not included):
dotnet publish -c Release -o .\.out
But this works:
dotnet publish -c Release -o .out
.NET Command Line Tools (1.0.0-preview2-003121)
Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
I am facing a similar issue on Debian 8.
.NET Command Line Tools (1.0.0-preview2-003131)
Product Information:
Version: 1.0.0-preview2-003131
Commit SHA-1 hash: 635cf40e58
Runtime Environment:
OS Name: debian
OS Version: 8
OS Platform: Linux
RID: debian.8-x64
When using the following from within the project directory:
dotnet publish -c "Release" --output ../../staging/published-website --no-build
I get the following output:

When using the following:
dotnet publish -c "Release" --output published-app --no-build
I am getting the correct output.
I was originally passing a relative project path to dotnet publish but I ran into this: https://github.com/dotnet/cli/issues/3528
Most helpful comment
I have another reproduction scenario.
This does not work (wwwroot is not included):
dotnet publish -c Release -o .\.outBut this works:
dotnet publish -c Release -o .out