Copy to Output - Copy Folder to Output

I don't see any way to mark a folder for "copy to output". 

Currently, I have tons of images that I have to set the properties on one at a time. (I could try making pattern match changes on the project file, but that comes with it's own set of problems).

4 comments
Comment actions Permalink

I have filed something close to your request to our tracker. Please feel free to upvote/comment
https://youtrack.jetbrains.com/issue/RIDER-9366

I am also curious, what problems do you have with wildcards?

Here are couple of examples:
<Content Include="fonts\*" />

for everything in the fonts folder

<Content Include="fonts\**\*" />

for everything in the fonts folder and its subfolders.

0
Comment actions Permalink

Apologies for the delayed response.  I missed this notification in my email.

I can edit the project and do something like this:

<ItemGroup>
<Content Include="assets\ui\**\*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

That seems to copy all my images to the bin folder on build (they are loaded at runtime), but I don't see a way to do this through the UI. 

Maybe a better request I could have made would be for a folder to have a properties setting that allows you to specify that its content should be copied to the output folder?

 

Or perhaps I'm missing something here?

 

Thanks.

 

 

0
Comment actions Permalink

Is the same approach supposed to work for Unit tests (NUnit)? I have folder with a subfolder that contains some files in the test project. I have marked one of the files to be always copied to the output folder via Rider UI. Then, I used 

System.IO.Directory.GetDirectories(".", "*")

and

System.IO.Directory.GetFiles(".")

inside a simple test to verify whether files/folder are indeed copied but I couldn't find any.

UPD: Apologies, I was wrong. File was actually being copied, just not in the path returned by 

System.IO.Directory.GetCurrentDirectory()

I was able to get the right path using 

Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)

from inside the unit test, however I'm not sure if there is a better way to get the same path.

Having said the above, I was still only able to copy individual files, not the whole folder with all of it's contents. Below are some more details on what I have attempted in case someone can spot what I'm doing wrong.

If I add files to the folders using UI, Rider generates something like this in the .csproj:

<ItemGroup>
<Content Include="TestAssets\Folder1\file1.txt"/>
<Content Include="TestAssets\Folder1\file2.txt"/>
...
</ItemGroup>

If I replace this item group with

<ItemGroup>
<Content Include="TestAssets\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

I can no longer see folders and files in Rider Solution Explorer (and they are not copied to output folder)

If instead of replacing auto-generate item group I just append the one above (with folder name and wildcard), I can see folders and files in solution explorer but they are still not being copied to the output directory.

0
Comment actions Permalink

Hm, changing Include attribute to

<Content Include="TestAssets\**">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

has worked. I was under impression that double asterisk means non-recursive wildcard, but I guess I was wrong.

With this notation I was able to remove individual auto-generated content entries.

1

Please sign in to leave a comment.