Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell compiler to copy wwwroot from one project to Tests proj?

Let's say I have this structure of projects:

- AppRunner
        | - Apprunner.csproj
        | - wwwroot


- Tests  
        | - Tests.csproj
        | - bin
                | - debug
                        | - netcoreapp2.1
                                        | - I want copy wwwroot here

I'd want to tell compiler to copy wwwroot with all items and folders inside to output folder of tests

but I'd want it to work fine not only on Windows but also on Linux

I addedd to Tests.csproj this:

<ItemGroup>
    <None Update="..\AppRunner\wwwroot\*">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
</ItemGroup>

but it doesn't really work

like image 838
Joelty Avatar asked Oct 01 '19 13:10

Joelty


1 Answers

In your Tests.csproj you could set up a link to your wwwroot folder:

<ItemGroup>
  <Content Include="..\AppRunner\wwwroot\**" Link="wwwroot\%(RecursiveDir)%(Filename)%(Extension)" CopyToOutputDirectory="Always" />
</ItemGroup>

In Visual Studio this will look like a regular wwwroot folder in your Tests project, but it is actually just a link to the folder in AppRunner. When you specify CopyToOutputDirectory this folder and its contents will be copied to the bin folder when you build the Tests project

like image 100
GTHvidsten Avatar answered Oct 05 '22 02:10

GTHvidsten