Quantcast
Viewing all articles
Browse latest Browse all 102

Visual Studio: is there a way to include resources in a Build?

I have a C++ Visual Studio project that depends on some resources (.glsl files).

Currently I have to copy and paste the resource directories each time I build the project, but that's quite unhandy.

I would like to know if there is a way to make the building process automatically include the resource files besides the generated .exe. If anyone could possibly provide some references too it would be appreciated, given that I can't find anything online.


The project structure is the following:

root |+-- resources |    | |    +- shaders |        | |        +- shader files (.glsl) |+- src files (.cpp/.h)

Current result after the release build:

Release |+- .exe+- .pdb+- DLLs

Desired result:

Release |+-- resources |    | |    +- shaders |        | |        +- shader files (.glsl) |+- .exe+- .pdb+- DLLs

Edit

As suggested by Minxin Yu - MSFT, I've tried using the Post-build events, with the following command:

PowerShell Copy-Item -Path $(SolutionDir)$(ProjectName)\resources  -Destination  $(SolutionDir)x64\Release\ -Recurse

But the build fails with the following error:

Build started...1>------ Build started: Project: 02es, Configuration: Release x64 ------1>Copy-Item : Impossibile trovare un parametro posizionale che accetta l'argomento1>'Righi\Programmi\GitHub\Fondamenti-di-Computer-Graphics-M\laboratorio\02es\resources'.1>In riga:1 car:11>+ Copy-Item -Path D:\Michele Righi\Programmi\GitHub\Fondamenti-di-Compu ...1>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1>    + CategoryInfo          : InvalidArgument: (:) [Copy-Item], ParameterBindingException1>    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.CopyItemCommand1>1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: The command "PowerShell Copy-Item -Path D:\Michele Righi\Programmi\GitHub\Fondamenti-di-Computer-Graphics-M\laboratorio\02es\resources  -Destination  D:\Michele Righi\Programmi\GitHub\Fondamenti-di-Computer-Graphics-M\laboratorio\x64\Release\ -Recurse1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(149,5): error MSB3073: :VCEnd" exited with code 1.1>Done building project "02es.vcxproj" -- FAILED.========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==================== Build started at 9:23 AM and took 02,321 seconds ==========

Viewing all articles
Browse latest Browse all 102

Trending Articles