Changing target directory for a pre-build command in VS 2005 - vb.net

I'm programming in VB using Visual Studio 2005 Professional.
I have a code munger perl script that generates some of the *.vb files that I want to compile. The script and the associated files are in my project directory, and when I run the script from the OS command prompt, it writes the files in the same directory, which is what I want.
Rather than do this, I want to invoke the perl script as a pre-build event. I've gotten it to work ... almost. The only issue now is that the files are now deposited in TargetDir (/bin/Release e.g.) instead of ProjectDir. I could just change TargetDir to be ProjectDir, but that seems like I'm asking for trouble.
Is there a way to separately specify the target directory for pre-build commands? Or change it to ProjectDir, then change it back after I'm done with the pre-build? Or maybe I just need to write a command that moves the files back where I want?
Thanks in advance!

You can simply prepend a cd command to your command:
cd ProjectDir
do_my_stuff
Your custom build step will be written out as a batch file by Visual Studio and run with cmd.exe, so cd commands will work just fine.

Related

How to fix 'VSTest.Console.exe' is not recognized as internal or external command

i am trying to run my MSTest from the command line, and I cannot for the life of me figure out why this isn't working. Yes it works if I manually change the directory to the executable, but I don't want to do that every time.
In the image below, you can see I have set up the environment variable, and yes I have restarted my computer many times.
You need to add it to your PATH variable. In that same dialog edit the Path variable and add the folder to the path. For example, I have enterprise installed, so I used this path:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow
After updating the path you will need to close and restart the cmd window.

How to replace dll files in program files by cmd/bat

I'm trying to do bat file which replaces some dll files under program files\file...
I just can't find solution to do this. I have some win xp and windows 7 computers to run this bat and I'm using xcopy command.
My file copy command is working correctly if destination is something else than under program files.
Does somebody knows the solution for this, please?
Your batch file needs to run elevated. In older windows versions you can also use the runas command to run it as administrator.

Executing Love2D scripts

The only way I found out to execute my script with the Love2d framework is to zip all of it and then rename the zip to love. This kinds of take a lot of time for a small modification. Is there a faster way to do it? I tried to command line and I get this error
'love' is not recognized as an internal or external command,
operable program or batch file.
LÖVE also executes folders if they have the main.lua in them - you can just drag and drop the folder onto the application, or call it from the command line with the folder as the argument if you prefer.
LÖVE runs the contents of a folder if it can find a main.lua in it (Like Bill said).
[Note that it doesn't check subfolders].
There are three ways to run a love2D program, you can:
a) Drag the folder over the love.exe binary/link (This works in Win and *Nix, I don't know about OS X).
b) Navigate to the directory that is one level above the folder and type love [folder containing main.lua]
or
c) Zip it up and rename the .zip to a .love. Then double click the .love file
Option 'b' will fail if the binary is not in the %PATH%(Windows) or $PATH(*Nix) variable
(It will spout an error message like 'love' is not recognized as an internal or external command, operable program or batch file. on windows and bash: love: command not found on linux).
There are two ways to solve this:
(Both require ADMIN/root privileges, )
1) Add the love binary to the PATH variable. Here's how to do this in windows and in linux (In linux you want to do something like this: PATH=$PATH:$HOME/where/ever/you/put/love/)
2) You can add a link to the love2D binary in C:\WINDOWS\system32 or /usr/bin/.
In windows you create a shortcut to the love.exe (wherever you installed it to) and then drag it into C:\WINDOWS\system32. In linux you can run this:
sudo link /path/to/love/binary /usr/bin/love && sudo chmod ugo+rwx /usr/bin/love
I hope this helps!
Sources:
Google (the links above), Love2D and my knowledge :D
I found this to be very helpful when i started. Hope this helps
A Guide to Getting Started With Love2d
If you're using Mac OS, you should run using:
open -a love xxx.love
To recreate a file as .love, you can run in command line:
zip xxx.love file1.lua file2
If you just want to replace a file in .love:
zip -r xxx.love file1.lua
I think this will make your work easier.
simple way:
create folder /path/to/Game
put your files (main.lua, conf.lua, ...) in folder /path/to/Game
you can run script like this:
love /path/to/Game/
or if you use Linux, you can go in folder (cd /path/to/Game) and type just:
love .
(dot means that you want to run it form in folder
I found a simple solution for save time.
You have to create a file .bat with this simple command:
del Project.love
7z.exe a Project.zip ..\Project\*
ren Project.zip Project.love
For do this you need to download 7zip and insert this file (file.bat) into the folder of your project. Like this:
Good work!
If you're yousing Notepad++ to write your code, just open your main.lua file, then go to Run and add there this text including quotes:
"Path" "$(CURRENT_DIRECTORY)"
Where Path is a Full path to love.exe.
The save it to a key combination and now you can test your code by using this combination in any script at Notepad++.
If you use Sublime Text, you can make a build which runs your application.
https://love2d.org/wiki/Sublime_Text
While in Sublime Text press CMD + B or Ctrl + B

running yiic from commandline fails after necessairy steps have been taken

I'm trying to install a Yii application with the latest framework to date on wampserver2.2.
I edited the .bat file to match the directory of my php /bin folder and added this as a value to the path variable.
However I seem to be unable to run yiic from the commandline. Im trying this on a windows 7 professional OS but to no avail. If i fire up yiic.php it opens the file in a notepad window. If I try to run the .bat file, the cmdline returns that it can not open the input file c:\wamp\framework\yiic
What should I do to make yiic run from the commandline? I think I completed all the necessairy steps but could be easily overlooking something.
If someone could come up with an answer that would be great.
Two things:
Make sure you are running yiic.bat, and not just yiic (which is the Linux shell script). There are two files in the directory, and your error (can not open the input file c:\wamp\framework\yiic) looks like you are using just yiic, the Bash script.
As #schmunk mentioned in the comment on the question, you can just call yiic.php directly with the PHP CLI. That is what the yiic.bat script is doing for you. :)
C:\wamp\framework> php yiic.php webapp C:\wamp\htdocs\myproject
I answered a similar question here that covers the same stuff:
https://stackoverflow.com/a/3728454/164439

How can I prevent Visual Studio from locking the xml documentation files in the bin directory?

My visual studio solution includes a web application and a unit test application. My web application uses log4net. I want to be able to use msbuild from the command-line to build my solution. However, whenever I build the solution from the command-line, I get build errors because it can't copy log4net.xml to the test project's bin directory.
The error message is:
"Unable to copy file '\bin\log4net.xml' to 'bin\Debug\log4net.xml'. Access to the path '\bin\log4net.xml' is denied."
It looks like Visual Studio is locking this file, but I can't figure out why it would need to. Is there a way to prevent VS from locking the XML documentation files in a project that it has loaded?
I've found the following solution:
In VS postbuild event or in NAnt/MSbuild script execute the cmd script
handle.exe -p devenv [Path to the folder with locked files] > handles.txt
FOR /F "skip=5 tokens=3,4 delims=: " %%i IN (handles.txt) DO handle -p %%i -c %%j -y
handle.exe is available here http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx
first line of the script dumps to handles.txt all handles for files locked by VS
second line reads handle ids from the file and kills the handles
After the script is executed files may be removed/replaced/moved etc
If you're fine with omitting the xml & pdb files altogether from the output, you can pass /p:AllowedReferenceRelatedFileExtensions=none to msbuild on the command line.
(Thanks to related answer https://stackoverflow.com/a/8757941/251011 )
EDIT: If you also have problems with dll files having this error, I recently discovered an environment variable solution: https://stackoverflow.com/a/23069603/251011
I've had this problem with Visual Studio, too. We use NAnt instead of MSBuild, but the problem is the same. I was able to work around it by modifying the build file to ignore failures when copying xml documentation.
Note that this doesn't actually solve the original problem since the xml files are still locked, but this workaround was good enough for us since the actual content of our xml documentation doesn't change very often.
Krystan wrote:
You could drop this file into another directory and reference it from there or place code that uses it into a library and have the post build event on that copy it to its bin directory and then reference.
Our xml file locking problem is not in the projects bin directory, rather an external reference directory. We hit it when performing TortoiseSVN->Update where a new version is available. Assuming it's because VS is using the file for intellisense.
For those who hit this locking issue due to TortoiseSVN->Update, I'm currently experimenting with a pre-update hook which deletes the offending file(s) before updating (they will be restored if no update is needed), so far this seems to work (which is weird) but I haven't tested it thoroughly enough to say for sure. Will update this answer if it proves reliable.
Here's hoping MS fix it in VS 2010.
Basically don't check files into the bin folder, its a bad idea.
You could drop this file into another directory and reference it from there or place code that uses it into a library and have the post build event on that copy it to its bin directory and then reference.
Msbuild will then copy that to the webprojects bin directory for you :)
We have this exact issue with people checking in stuff to the bin directory, unless you absolutely have to bin directories should either not be checked in at all or just have .refresh files in there to avoid these sorts of locking issues.
Bit late on the reply, sorry :)