Post-build event command line; how to level up in path and how to handle spaces - post-build-event

My goal is to copy a XML file from one project to another project in my solution after a succesful build.
copy $(SolutionDir)Xenos.Core.API\XmlDocumentXenosCoreApi.xml $(ProjectDir)App_Data\XmlDocumentXenosCoreApi.xml
This would translate in this.
copy D:\XENOSTFS2015\Sprint Development\Diversification Sprints\Xenos Main\Xenos.Core.API\XmlDocumentXenosCoreApi.xml D:\XenosTFS2015\Sprint Development\Diversification Sprints\Suite\XenosWebAPI\App_Data\XmlDocumentXenosCoreApi.xml
But I want the first argument of copy to be like this, so the solutiondir should go two levels up. A
D:\XENOSTFS2015\Sprint Development\Diversification Sprints\Suite\XenosCoreApi\XmlDocumentXenosCoreApi.xml
Also I'm worried that the spaces will prevent the copy from executing, how can I solve this?
Thx in advance !!

Related

Batch file doesn't work properly unless I'm watching it

I've searched for a solution to my issue, but it's strange and I can't exactly figure out where it's going wrong.
I have a batch file that seems pretty straightforward. In a directory that has two files, it's supposed to delete one, copy the other, then rename it to what the file just deleted was named. Everything seems to work properly except for the renaming. It almost appears that the script runs twice, but I can't find any actual evidence of this. Please see below:
SET filepath="\\server-name\directory with a space\"
SET oldFile=filename.csv
SET curFile=filename_*.csv
REM ===Delete current filename.csv===
IF EXIST %filepath%%oldFile% DEL %filepath%%oldFile%
REM ===Copy all versions of .csv files that begin with filename_ to the Archive folder===
IF EXIST %filepath%%curFile% COPY /y %filepath%%curFile% %filepath%%Archive
REM ===Rename the .csv file beginning with filename_ to filename.csv===
IF EXIST %filepath%%curFile% RENAME %filepath%%curFile% %oldFile%
If I run this manually, it appears to work fine. However, when I let it be called from a Scheduled Task, it appears to run twice... that is, it deletes the filename.csv, copies the filename_*.csv to the correct place, but then seems to delete the second file rather than rename it.
As I said, I'm really unclear on what is actually being done. I've tried logging the results in an output file, but there isn't anything helpful within.
Can anyone see anything I'm missing?
Thanks in advance.
Examine
IF EXIST %filepath%%curFile% COPY /y %filepath%%curFile% %filepath%%Archive
Note that archive appears to have a leading % - is this meant to be a directory "archive" or is archive set to something you're not showing us and therefore it should be ...%filepath%%Archive%
The consequence of the (?missing/stray %) is that the file would be copied to a file named archive or to a directory named archive if that directory already exists.
Personally, I'd use
SET "filepath=\\server-name\directory with a space"
where the quotes delimit the string to be assigned (so no stray trailing spaces are assigned to the variable) and then construct the source/destination names using "%var1%\%var2%" which ensures no double-" appear and the directory is obvious (but this is a matter of style).
It is a best practice to quote paths. In this case, where a space is involved, it is a requirement. It is easier to omit quoting from the varaiable definition and provide them where needed when the variable is used.
SET filepath=\\server-name\sharename\directory with a space\
IF EXIST "%filepath%%oldFile%" DEL "%filepath%%oldFile%"
In my experience, it is best to leave the directory at the end of a path without the trailing backslash. Also, a UNC path should have a sharename.
SET "filepath=\\server-name\sharename\directory with a space"
IF EXIST "%filepath%\%oldFile%" (DEL "%filepath%\%oldFile%")
I've finally discovered the solution to this. Turns out there was a copy of the task running on an older server that our new environment had been migrated from. It was running at the exact same time as the one on the new server, which is why it would run perfectly fine any way I tried to run it before or after the time the task was set to run. Disabling the old version of the task resolved the issue.
Thank you to those who provided feedback and suggestions on my commands!

Files not under caret on new computer

I opened my project on another computer, and the files where I'd been using a file watcher were expanded, like before they used to be nested like home.scss is now after I run the watcher once on that file.
Is there a way to automatically make all the files be nested?
Because when adding new files and folder with git, it would be quite troublesome to go into each and every file in order to make them become nested.
Like I have some minified JavaScript files that used to be nested, but now is expanded for some reason.
Hope you understand. Thank you.
Edit: Nested***
Is there a way to automatically make all the files go under a caret like that?
Unfortunately not. Such nesting information (to "go under a caret" as you are saying) is taken from "Output path to refresh" field of the corresponding File Watcher.
You have to run file watcher for such files at least once in order to see files nested like you have it on your another computer.
Here is how you can run File Watchers manually without the need to modify those files (so no extra history will appear in your git (or whatever VCS you may be using there)).
https://stackoverflow.com/a/20012655/783119
P.S.
In PhpStorm 2016.3 (the next version that will be released in 1.5-2 months or so) such nesting will be done automatically (the most common combinations) so there will be no need to have File Watchers for providing such info.
If you wish -- you can try EAP build right now (EAP means Early Access Program .. which is sort of Alpha/Beta builds (simply speaking).. and therefore some bugs for new functionality might be present and performance may not be optimal).

In monodevelop how can I clear out the Task list?

My task list pad is filled with old //Todo comment tasks that have been parsed out of the code. Unfortunately the files they refer to have long since gone and the tasks are hanging around like zombies. Deleting each task simply throws an error that the file is missing. How can I manually force a complete cleanout of the tasks list so it can reparse? I had a quick look at the source code for this part of MD but I didn't see anything obvious.
I'd suggest you file a bug.
However, for a quick workaround, try deleting the code completion database caches. On Mac you can find them in ~/Library/Caches/MonoDevelop-3.0/DerivedData, and on Windows they're in AppData\Local\MonoDevelop-3.0\Cache\DerivedData.

Hard link to a file not working as expected on OS X

I've a file in a folder and I don't know anything about this file (how it's generated and updated) because it comes from an application running on my system of which I don't have the source code.
The file format is clearly json and I successfully created an hard link to it (using the shell command ln file hardLinkToFile) and placed it on another directory.
At this point I check the "2" files and they are exactly the same as expected, but when I perform an action in the application that cause an update of the original file the hard link doesn't get updated.
Any idea on how I can solve this problem?
UPDATE: As pointed out by both Vlad Lazarenko and mvds the file probably get deleted and a new one is created, is there something I can do to obtain a solution equivalent to the hard-link one I thought initially about?
If a hard link is not getting updated, it means that application is removing the old file and creates a new one. Thus, you still have a hard copy of the previous file, but new file has a totally different inode, though path is still the same. You can verify it simply by changing the content of that file yourself - the link should get updated.
I am getting the same behavior in TextEdit, but not in TextMate. I would suspect this is due to the revision control built in to OS X Lions document architecture. TextEdit uses versioning, while TextMate does not. Most likely this function replaces the file instead of changing it, as described by #Vlad Lazarenko.
#Vlad and Francesco. It's really in this way. I verified that vi leaves the inode unchanged and the src and dest file are both changed, while e.g. the kate editor doesn't and I was getting mad to understand why the changes I made in the src file weren't also in the dest file.
You can easily check this with the command ls -li srcfile destfile before editing one of them with each editor I mentioned.
By the way it's not nice that the hard link are application dependent
I guess it is a bit too late...
Anyways, accidentally I found that, if you change the default app for the file, the hard link gets separated from original file. Even if you click on change all and do not relate to that specific file.

Autocompletion based on filenames in a directory

I want to have a function in my zsh for faster accessing my todo-files. It should look inside the folder ~/tasks where i put my todo-lists and stuff. Now i want to type task p and when I hit tab, it should use the files in that directory for autocompletition. Can anyone point me some direction? Or share some snippet to work with?
Thanks
This would seem to do the trick:
compdef '_files -W "$HOME/tasks"' task