Reputation: 10400
I have the following Post-Build event defined in my project:
if "$(ConfigurationName)"=="Release" ("$(ProjectDir)PostBuildRelease.bat" "$(TargetDir)")
So when I build the project in release mode, the following .bat
file is executed:
PostBuildRelease.bat
CMD
SET parameter=%1
CD %1
ECHO "Copying temporary file..."
COPY FileDeleter.exe temp.exe
ECHO "Merging dependancies..."
"..\..\ILMerge.exe" /out:"FileDeleter.exe" /targetPlatform:"v4" "temp.exe" "Microsoft.WindowsAPICodePack.dll" "Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll" "Microsoft.WindowsAPICodePack.Sensors.dll" "Microsoft.WindowsAPICodePack.Shell.dll" "Microsoft.WindowsAPICodePack.ShellExtensions.dll"
ECHO "Removing temporary file..."
DEL temp.exe
All it does is copy the assembly to a temporary location, merge the required dependancies into a final executable FileDeleter.exe
, and then removes the temporary file.
This worked fine when the project was saved to a local drive, but after moving the project to a network drive, I get these errors when building in Release mode:
'\\file\IT\Internal Apps\AppDev\Applications\WpfFileDeleter\WpfFileDeleter\bin\Release\'
CMD does not support UNC paths as current directories.
C:\Windows>"Copying temporary file..."
The system cannot find the file specified.
"Merging dependancies..."
'"..\..\ILMerge.exe"' is not recognized as an internal or external command,
operable program or batch file.
"Removing temporary file..."
Could Not Find C:\Windows\temp.exe
CMD complains about not supporting UNC paths.
However, I know that the drive in question (\\File
) is actually mapped to the Y:\
drive - so I can navigate to the directory in CMD by targeting Y:
instead of \\file\
.
The question is - how can I get Visual Studio to recognise this drive mapping by default, after all my projects have been moved to this network drive?
Upvotes: 1
Views: 4289
Reputation: 143
I've learned that batch dosnt like going over a network dir unless you add it as a drive with pushhd
. This has worked for me like a charm when working over the network.
PUSHD is an internal command. If Command Extensions are disabled the PUSHD command will not accept a network (UNC) path."
Source: http://ss64.com/nt/pushd.html
Upvotes: 1
Reputation: 10400
I was able to find a solution to this using this answer:
.csproj
file, making sure to navigate to it using the mapped drive, (i.e. Y:\folder\test
instead of \\file\folder\test
)TargetDir
variable will be set using the mapped drive instead of \\file
, meaning that no changes are necessary to the post-build event or the batch file. Another option, as I am using Team Foundation Services in VS, is to remove all existing local git repositories from Team Explorer
-> Manage Connection
-> Local Git Repositories
and then re-adding the same locations, but again when navigating to the folder, use Y:\
instead of \\file
.
Now any project I open from these repositories automatically has their TargetDir
paths set using the mapped drive.
The other answer here also worked, but requires changing the post-build event to use the hard-coded mapped path as well as changing the batch file to use PUSHD
instead of CD
.
Upvotes: 0