Visual Studio prebuild event for deleting certain file with naming convention - visual-studio

I am using prebuild event commands to delete certain folders in my wwwroot directory.
Now, I need to do that for certain dll's in the bin folder that follow a certain naming convention like,
Foundation.*.dll
Currently, I am using the following to delete a directory:
rd /s /q "C:\inetpub\wwwroot\siteroot.local\App_Config\Include\zzz.Project"
I need a variation on this to delete just certain dlls.

del /s /q "C:\inetpub\wwwroot\sc.vitas-p.local\bin\Project.*.*"
This wound up being the answer.

Related

How to delete files in folders and all subfolders which contain specific string in file name?

I have folder where I have tons of other subfolders and each of them contains files like
original_file1.jpg
original_file1_t1.jpg
original_file2.jpg
original_file2_t1.jpg
and so on
I would like to remove all of them from within Windows command prompt and I tried that with
del /s *_t1.*
But it is only removing files within folder that I am currently.
How to do this with code that will check every folder within this location?
The structure of folders looks like this:
Main_folder/album_1/original_file1_t1.jpg
Main_folder/album_2/original_file1_t1.jpg
and so on
Ok, I am so sorry for posting this thread but I found the solution.
When You are in your main folder just use
del /s /q *_t1.jpg

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.

Deleting log files windows

I need to make a batch file that can search the hard-drive for log files and remove them. Does any one know a code that I can use. I am using windows 7.
If you are certain that all *.log files on a drive can be deleted with no after effects, then this will delete the log files that are not in use:
#echo off
del \*.log /s /f /q

How to create an installer of a browser-based system?

I just developed a browser-based employee management system. I am wondering if there is a way for me to create an installer or a self-extracting file to transfer the system to another computer easily.
I have tried using "iexpress.exe" and "Actual Installer" however it seems they only extract in a single directory. Is there a way for me to specify which file should go to a specific directory using these applications? If none, any suggestions how to do it?
You can make IExpress put files into subdirectories using a technique described by Microsoft. In your install program, you’d need to do something similar to:
#md i386
#xcopy /q /y toastva.exe i386\.
#xcopy /q /y tostrcls.dll i386\.
#xcopy /q /y tostrco2.dll i386\.
#xcopy /q /y toaster.sys i386\.
(You could use move /y instead of xcopy, if that’s what you wanted to do.)
This is due to a technical limitation in the way IExpress generates its CAB file. IExpress generates a DDF file which is read by makecab.exe; this file places all source files in the same destination folder. Thus each source file must have a unique name, regardless of its source directory.
While makecab.exe itself supports subdirectories, the input DDF file is generated on-the-fly by IExpress, so it would be difficult (if not impossible) to intercept it and make changes before makecab.exe reads it.
But honestly, if you need subdirectories (and sub-subdirectories…) then you might want to consider using a "real" installer maker. Some examples in no particular order:
Inno Setup
NSIS
WiX

Visual Studio: references in code not recognized?

I have a solution in VS2008 (C#) that contains multiple projects. I just retooled some of the .csproj files for our build process, and suddenly while coding Project B won't recognize references from Project A in the class code...think the red squiggly lines under a variable type I've created. However, building the solution generates no errors. Why's it behaving like this?
I would suggest that you clear your Visual Studio temp files - it can often get confused about project structures and require a fresh start.
First, quit out of VS completely and restart it. If the problem is still there, find your VS cache folder and delete it, and then do a rebuild.
For help finding your cache folder, check this post.
When VS starts acting strangely wonky, and I can't find a logical fix, I kill Visual Studio, and manually do a 'clean' by deleting all of the bin/obj folders.
I have a batch file that does this for me quicker than I could do it manually. I place this in my solution directory, and all my projects are found in subdirectories.
rem "%%~dpa" says: Give me the (d)drive and (p)path of the (a, %%a) file.
rem However, our dir /a:d will result in only listing folders...
rem The final "%%a" is just appending the 'file' (diretory name) to the
rem drive-and-path string
for /f %%a in ('dir /b /a:d *.*') do call :process "%%~dpa%%a"
pause
goto :eof
:process
echo Looking in %1
cd "%1"
if EXIST "%1\bin" (
echo Found 'bin' - it's gone now.
rd /s /q "%1\bin"
)
if EXIST "%1\obj" (
echo Found 'obj' - it's gone now.
rd /s /q "%1\obj"
)
cd ..
Another solution
If the other answers regarding clearing Visual Studio cache, .NET Cache, and
ensuring references are valid don't work, try this one.
Based on the source, and trying this solution, I've had success.
Deleting the visual studio solution cache folder
Close out of all instances of visual studio
Locate the .vs hidden folder within your solution.
Delete the entire hidden .vs folder.
Rebuild the solution
-- Source
In your Project Properties from B, make sure Project A is checked under dependencies.
Make sure both projects are being built in the Configuration Manager
(right click on the solution and then click “Configuration Manager”)
You might also hover over the redline or just build again to see if you get anymore details. C# and VB are both pretty good at telling you why they not happy.
I've removed the reference from the project which classes were not recognized and re-added this reference. Everything got fixed.
Double check that you made the classes you are referencing public. Visual Studio doesn't do it automatically when you make a new class and I sometimes forget.

Resources