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.

Allow copying empty directories with <Content>

See original GitHub issue

This issue has been inspired by dotnet/cli#2911. In short, if I specify something like this:

<ItemGroup>
    <Content Include="logs">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
</ItemGroup>

MSBuild will throw an error saying that the Copy task does not support copying directories. I can put in a glob, but if there are no files, nothing gets copied out (with a glob the why of that behavior is clear to me at least).

/cc @moozzyk

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
WildBamboocommented, Mar 15, 2017

Ok, so publishing in VS is sorted now, but I’m guessing the FileSystemPublish target doesn’t run when using the cli dotnet publish src\myproj.csproj --framework net462 --output "c:\temp" --configuration Release since the log folder is not present at c:\temp\logs.

So I’ve now got one target for cli/VSCode, and one for VS:

  <Target Name="CreateLogsFolderDuringCliPublish" AfterTargets="AfterPublish">
    <MakeDir Directories="$(PublishDir)logs" Condition="!Exists('$(PublishDir)logs')" />
  </Target>

  <Target Name="CreateLogsFolderDuringVSPublish" AfterTargets="FileSystemPublish">
    <MakeDir Directories="$(PublishUrl)logs" Condition="!Exists('$(PublishUrl)logs')" />
  </Target>

I can go home now 😃

2reactions
dasMullicommented, Mar 14, 2017

However, I’m guessing the web targets would also need support for folders as items to get that out of the box - so we’re back here.

In the meantime, we can of course hook into file system publish:

<Target Name="CreateLogsFolderOnFileSystem" AfterTargets="FileSystemPublish">
  <MakeDir Directories="$(PublishUrl)Logs" Condition="!Exists('$(PublishUrl)Logs')" />
</Target>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow copying empty directories with <Content> · Issue #1586
MSBuild will throw an error saying that the Copy task does not support copying directories. I can put in a glob, but if...
Read more >
Ant Copying Empty Directories
Only files and the top-level directories are being copied. ... You can include copy of empty directories as follows.
Read more >
Robocopy /S creates empty folders
There is a simple workaround to quickly remove the empty directories in the destination location which entails running Robocopy <dest> <dest> /S ...
Read more >
Copy Files task does not copy empty directories
Copying empty subdirectories can be very important. I found a similar issue about the Publish Artifacts task not copying empty folders: https:// ...
Read more >
Copy Folder Structure without Copying Files in Windows
Using the XCOPY command​​ The built-in XCOPY command in Windows can copy the directory or directory tree (i.e., recursively). The switches /T /E ......
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