简体   繁体   中英

Visual studio Copying a project folder to Output Directory (WPF solution)

Under VS2017 I have a WPF solution that contains two projects.

I Added a "Bin" folder at SolutionDirectory level to put the generated dlls of both projects inside.

In one of my projects i have two folders that contain some xml files and a server config file.

When the build runs i would like these two folders be copied to the OutputDirectory that i created (SolutionDirectory\Bin) under a folder that have the same name of my project

Content of my solution:

-->SolutionDir
   |-->Solution.sln
   |-->MyFirstProject (Folder)
   |-->MySecondProject(folder)
   |-->Bin (Folder where dlls are generated)

Content of my MyFirstProject:

-->MyFirstProject
   |-->Configuration
      |-->Server.Config 
   |-->Topology
      |-->StartupVar.xml
      |-->SystemData.xml

what I want:

-->Bin
   |-->MyFirstProject
      |-->Configuration
      |-->Server.Config 
   |-->Topology
      |-->StartupVar.xml
      |-->SystemData.xml

   |-->MyFirstProject.Dll
   |-->MySecondProject.Dll

To copy the project DLLs I have used the Post-build event command line:

copy /Y "$(TargetDir)$(TargetName).*" "$(SolutionDir)\Bin"

I tried to do the same to copy the folders "Configuration" and "Topology" but it doesn't work.

How can I do this through Post-build event command line? or what is the best way to do it?

If the problem is that the COPY command doesn't create the destination folder, try using XCOPY instead, as one of your post-build commands:

xcopy /Y "$(ProjectDir)\Topology" "$(SolutionDir)\Bin\$(ProjectName)\Topology\"

Be sure to include the terminating \ . (The /Y switch prevents a confirmation before over-writing existing files.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM