2016-11-10 44 views
1

我已经在我的项目定义如下生成后事件:如何获得Visual Studio来识别一个网络驱动器映射

if "$(ConfigurationName)"=="Release" ("$(ProjectDir)PostBuildRelease.bat" "$(TargetDir)") 

所以,当我建立在释放模式的项目,执行以下.bat文件:

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 

它所做的就是装配复制到一个临时LO将所需的依赖关系合并到最终可执行文件FileDeleter.exe中,然后删除该临时文件。

这工作得很好,当该项目被保存到本地驱动器,但该项目移动到网络驱动器后,我建立在Release模式时,得到这些错误:

'\\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抱怨不支持UNC路径。

但是,我知道有问题(\\File)驱动器实际上是映射到Y:\驱动器 - 这样我就可以通过瞄准Y:而不是\\file\导航到CMD的目录。

问题是 - 在我的所有项目移动到此网络驱动器后,如何让Visual Studio默认识别此驱动器映射?

+0

给它绝对的网址。例如Y:\ FileDeleter.exe从驱动器开始。您应该拥有对该驱动器的读写权限。 – karman

+0

如果以管理员身份运行,则只能访问映射为管理员的驱动器。 – 2016-11-10 11:36:14

+0

@karman感谢您的评论 - 请参阅下面的答案和我的解决方案的评论。我不知道是否有任何方法让VS自动将当前目录设置为映射的URL – Bassie

回答

1

我已经了解到,批量dosnt就像通过网络目录一样,除非您将其作为驱动器添加到pushhd。在网络上工作时,这对我来说很有用。

PUSHD是一个内部命令。如果命令扩展名被禁用PUSHD命令将不接受网络(UNC)路径“

来源: http://ss64.com/nt/pushd.html

+1

这与在生成后事件中传递绝对URL一起工作:if if $(ConfigurationName)“==”Release“ (“$(ProjectDir)PostBuildRelease.bat”“Y:\ Internal Apps \ AppDev \ Applications \ WpfFileDeleter \ WpfFileDeleter \ bin \ Release \”) – Bassie

+0

很高兴我可以帮助:) – NizonRox

+0

我也加了我自己的答案,找到有用的 – Bassie

0

我能够使用this answer找到一个解决这个:

  1. 从Visual Studio解决方案中删除项目
  2. 右键单击解决方案并单击“添加现有项目”
  3. 导航到.csproj文件,确保使用映射的驱动器导航到它(即,​​代替\\file\folder\test
  4. 现在,一旦该项目被添加时,TargetDir变量将被使用,而不是\\file映射驱动器设置,这意味着没有必要改变生成后事件或批处理文件。

另一种选择,因为我使用的Team Foundation服务在VS,是从Team Explorer删除所有现有本地Git仓库 - >Manage Connection - >Local Git Repositories,然后重新添加同一位置,但时再导航到该文件夹​​,请使用Y:\而不是\\file

现在我从这些存储库中打开的任何项目都会自动使用映射驱动器设置其TargetDir路径。


这里的其他答案还努力,但需要改变使用硬编码映射路径生成后事件以及改变该批处理文件使用PUSHD,而不是CD

相关问题