In Visual Studio 2013 copy files to the release directory only - visual-studio-2013

I have some files in my project that are used for unit testing, and than files that will be used in the actual release.
Currently have 'Copy to output directory' copy always turned on.
Is there a more direct way to send only certain files to the 'Release' directory and others to the 'Debug' directory when building?

I ended using the command line build events property in the MAIN/Solution project.
yourproject > properties > build events
Pre build event command line
First i cleaned out the directory
rd /s /q "$(TargetDir)Configs"
Post-build event command line
Next on Debug, copy all.
And on Release, del everyting that was for testing.
if "$(ConfigurationName)"=="Debug" (
xcopy "$(ProjectDir)Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\_notes.*"
)
if "$(ConfigurationName)"=="Release" (
xcopy "$(ProjectDir)Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\test*.*"
del "$(TargetDir)Configs\_notes.*"
)
IN the test Project, used the same PRE command.
Had to change the POST command a little.
if "$(ConfigurationName)"=="Debug" (
xcopy "$(SolutionDir)$(SolutionName)\Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\_notes.*"
)
if "$(ConfigurationName)"=="Release" (
xcopy "$(SolutionDir)$(SolutionName)\Configs\*.*" "$(TargetDir)Configs\" /y
del "$(TargetDir)Configs\test*.*"
del "$(TargetDir)Configs\_notes.*"
)
I think this could be slimmed down, but its working.

Related

Windows Command to delete existing directory and create new

I have a "release" folder inside c:\data.
I would like to delete the entire "release" folder, its sub directories and all files inside them using windows commands. After deleting it, I need to recreate the "release" folder and add another folder "app" inside "release" folder using commands.
I tried using rd /s and few other commands but it complains about non empty directory and workarounds to re-try rd /s command. I thought it should be fairly easy to do. Does anyone have a script / commands for them?
You can of course remove (rd) and recreate (md) a directory. However, you will lose its attributes then (like Hidden or Owner).
To maintain attributes, remove the contents of the directory but not the directory itself, either doing something like this:
rem // First remove all sub-directories with all their contents:
for /D %%I in ("C:\Data\release\*") do rd /S /Q "%%~I"
rem // Then delete any files located in the target directory:
del /Q /A "*.*"
Or this:
rem // Change into the target directory:
cd /D "C:\Data\release"
rem /* Try to remove the target directory and all its contents; since you are
rem in the target directory, it cannot be removed, although its contents can;
rem the `2> nul` portion suppresses the error message about access problems: */
rd /S /Q "." 2> nul
RM is not a windows cmd command. This should work:
IF EXIST "c:\data\" (
RD c:\data\release /S /Q
MD c:\data\release
MD c:\data\release\app
)

Xamarin Forms Android Emulator not attaching to debug

I'm running Visual Studio 2017 with Xamarin Forms using a shared project type. When I run the Android emulator in debug mode it will work properly once, but as soon as I make a code change, it does not attach to the code unless I delete the virtual device, re-create it and restart VS.
Clearing the cache in the Android Emulator Manager does not work, neither does cleaning and rebuilding. What am I missing?
Try Below Solution:-
create text file and write below code in it :-
FOR /F "tokens=" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
FOR /F "tokens=" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
Now save this file with SamplefileName.bat with .bat extension.
Make sure while saving "select Save As Type" option as "All Files".
Now you need to place this .bat file into your Solution Directory where your project .SLN file resides.
This .bat file will delete the bin and obj folders from the project solution
Next step is now run this bat file whenever you make code changes and you want the debugger should work after the changes.
You may not need to close and reopen the emulator/ Genymotion vertual device

post-built event xcopy fails with exit code 4

my Xcopy fails to execute properly after I compile my project.
xcopy "$(SolutionDir)LuaModules\*.*" "$(TargetDir)Modules\" /S /H /Y /C
You have unneeded slash after /S.
$(SolutionDir) gives the directory where the solution is in, but the project ($ProjectDir) gives the folder of your files. I had to use that instead

Copying folders on post build in Visual Studio

Lets say I have a project solution, I want to copy the contents of bin/Release folder after the build into another folder named "Deploy"
Source: D:\Solution\bin\Release
Destination: D:\Destinationfolder\bin\deploy
the macros are as follows
TargetDir : D:\Solution\bin\Release
ProjectDir: D:\Solution
I have tried this
xcopy /? $(TargetDir) $(ProjectDir)\..\Bin\Deploy /R /Y /S
This is not working. Am I doing anything wrong? Is there any other way to do this?
Remove the /? from the xcopy command, and add quotes around paths. The .. will take the $(ProjectDir) path back to D:, so the Destinationfolder should also be added.
So: xcopy "$(TargetDir)" "$(ProjectDir)\..\Destinationfolder\Bin\Deploy" /R /Y /S
I would suggest you to create a Publish Profile. If you want to build the project to a desired folder you can simply right click on the project and click Publish.

Batch copy command doesn't reach subfolder

I have a batch command to copy and move file with a new name to another directory. When I added one more level of subfolder it does not copy but when I remove the added subfolder and move the file to the previous level it does copy. Here is it is:
cd /d dir "U:\Sourcing\Vendor Demand Planning\Customer CPFR\BBM\"
for /f "delims=" %%I in ('dir /b /o:-d "BBM Tool *.xlsx"') do (
copy "%%I" "..\Pricing Project\BBM Tool.xlsx"
exit /b
)
If I removed the BBM level and move the file into the Customer CPFR level it works. I edited this batch from another one that had the target file in the CPFR folder. The file I need to copy is in the BBM folder.
Change COPY to XCOPY and use /S
See XCOPY /?
I'd say that the "Pricing Project" directory is on the same level as "Customer CPFR" hence the target of the copy should be "..\..\Pricing Project...
(later edit)
Also dir in the CD line should be removed.

Resources