✅ Copy files generated by command to build output
During a build, I want to run a command to build a Vue project which outputs its files to a folder, then copy the files from that folder to a
wwwroot
folder in the project's build output. How would I do this? I know I can use Exec
to run the command which works fine, but I don't know how I would copy the files properly while preserving the subfolder structure.27 Replies
we do that in the dockerfile at work. Not an answer to your question, but perhaps an alternative
1. You have a problem
2. Use Docker to solve problem
3. You have two problems
😄
I'm not using Docker in this project (yet) so that feels very overkill
sure
you could check how the
dotnet new react
project template does it
it does it with msbuildyeah at this point idk why this doesn't work
have you tried looking at a binlog
okay now I'm using this from the React template ...and it's still not working
As in, the wwwroot just doesn't appear in the
bin/release/net8.0
folderyou are sure that
npm run build
actually happens, rightit absolutely does
okay this is the entire target
Most of this is copied from the React template and I don't get what is wrong
I tried changing
$(VueProject)dist\**
to @(VueProject)dist\**
but that caused an error saying The expression "@(VueProject)dist\**" cannot be used in this context. Item lists cannot be concatenated with other strings where an item list is expected. Use a semicolon to separate multiple item lists
.
Another thing which does not work
Doesn't do anything either
And there doesn't seem to be a difference between OutputPath
and OutputDir
I have no idea what I'm doing wrong
Idk how to debug this evenlooking at the binlog would help
where is that?
oh you don't even know
https://msbuildlog.com/
odd, there's only one parameter to the copy task
do you see any Add Item elements in the target
There's one for
VueProject
, but none for the DistFiles
can you try
"$(VueProject)\dist\**"
For
SourceFiles
in the copy task, or DistFiles
?for DistFiles
no difference afaict
okay I think the issue is that
$(VueProject)dist
doesn't exist
it refuses to allow me to concatenate god damn strings just refuses to work
If I do <Message Text="$(VueProject)\dist" Importance="high" />
then it just prints \dist
So VueProject
doesn't exist???
It lets me do <Message Text="@(VueProject)\dist" Importance="high" />
which prints it properly, but doesn't let me do <DistFiles Include="@(VueProject)\dist\**" />
because it can't concatenate strings??????
why doesn't this work
again <DistFiles Include="$(VueProject)\dist\**" />
doesn't even show up in the log
like what
It's clearly there but it refuses to workoh. VueProject is an item. $(VueProject) does not do anything
feel so dumb
THIS WORKS
So if I just don't use
VueProject
then it's fine, it's just kinda uglieri mean. you can just make VueProject a property instead
yeahhhhh I realized you could do that
this entire thread has just been me not knowing anything about msbuild
seriously thank you so much @reflectronic
on another note, it's 2 am and I need to sleep
enjoy