Search code examples
batch-filevisual-studio-2015cmdunc

How to get Visual Studio to recognise a network drive mapping


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?


Solution

  • 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