Jeff Huckins
Jeff Huckins

Reputation: 23

I'm unable to find a way to conditionally copy files based on platform in a post build event in Visual Studio 2022

I have a .NET 6 WPF application with 52 projects. For one of the projects, I need a post-build event to copy files from one directory if the Platform is "Any CPU" and from another directory if the Platform is "x86".

I've tried many things I've found from Google searches, but have been unsuccessful.

What I have at this point is:

if $(PlatformName) EQU "Any CPU" ( xcopy "$(SolutionDir)MyFiles_64\*.*" "$(SolutionDir)SysBin\WebView2\" /s/c/r/y/d )

if $(PlatformName) EQU "x86" ( xcopy "$(SolutionDir)MyFiles_32\*.*" "$(SolutionDir)SysBin\WebView2\" /s/c/r/y/d )

Upvotes: 0

Views: 36

Answers (1)

user20716902
user20716902

Reputation: 1393

You want to use if () ELSE () like below:

if $(PlatformName) EQU "x86" (
   xcopy "$(SolutionDir)MyFiles_32\*.*" "$(SolutionDir)SysBin\WebView2\" /s/c/r/y/d 
) ELSE (
   xcopy "$(SolutionDir)MyFiles_64\*.*" "$(SolutionDir)SysBin\WebView2\" /s/c/r/y/d
)

Upvotes: 0

Related Questions