sco*_*ooz 11 projects-and-solutions visual-studio-2008 visual-c++
我在VS2008中有一个带有多个项目的C++解决方案.此解决方案包含运行时所需的文件,这些文件根据相对于解决方案目录的路径加载(例如"Testing/data/" + "dataN.bin"
).
为了使此解决方案起作用,我必须在项目中设置工作目录设置,以便它指向解决方案目录(例如Configuration Properties >> Debugging >> Working Directory = $(SolutionDir)
).当我在自己的电脑上调试时,这很好用.但是,当其他用户加载我的解决方案时,他的项目没有正确设置此属性.
我跟踪此设置不是存储在项目文件(PROJECT.vcproj
)中,而是存储在为其创建的用户特定文件中(PROJECT.vcproj.DOMAIN.USER.user
).
我想为所有用户存储此设置的方法,而不必一次又一次地手动设置.
我的想法是:
但是,我没有找到办法做其中任何一个.
一些注释/限制:
任何帮助将不胜感激...提前感谢.
vah*_*apt 10
PROJECT.vcproj.user文件示例如下
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioUserFile
ProjectType="Visual C++"
Version="9,00"
ShowAllFiles="false"
>
<Configurations>
<Configuration
Name="Release|Win32"
>
<DebugSettings
Command="$(ProjectDir)..\Deploy\$(ConfigurationName)\$(TargetFileName)"
WorkingDirectory="$(ProjectDir)..\Deploy\$(ConfigurationName)\"
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="LOCALHOST"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="0"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
<Configuration
Name="Debug|Win32"
>
<DebugSettings
Command="$(ProjectDir)..\Deploy\$(ConfigurationName)\$(TargetFileName)"
WorkingDirectory="$(ProjectDir)..\Deploy\$(ConfigurationName)\"
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="LOCALHOST"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="0"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
</Configurations>
</VisualStudioUserFile>
Run Code Online (Sandbox Code Playgroud)
不存在这样的财产。还有更大的问题,这也需要在部署解决方案后起作用。那么工作目录将不会是“解决方案”目录,目标计算机上没有这样的目录。
假设工作目录与 EXE 目录相同,那么您的工作效果会更好。这将是调试时和目标机器上的默认设置。您可以通过链接器设置完全控制 EXE 文件的位置。您可以通过获取代码中的 EXE 目录来保护自己免受使用另一个工作目录运行程序的快捷方式的影响,以便生成绝对路径。使用 GetModuleFileName(),传递 NULL 来获取 EXE 文件的路径。
另一个标准解决方案是将 EXE 所需的任何类型的资源复制到与构建输出文件夹相对的文件夹中。您可以使用预构建事件来执行此操作,使命令行看起来与此类似:
if not exist "$(OutDir)\Testing" md "$(OutDir)\Testing"
xcopy /d /s "$(SolutionDir)\Testing\*.*" "$(OutDir)\Testing
Run Code Online (Sandbox Code Playgroud)
请注意 /d 选项如何确保仅在测试文件夹内容发生更改时才进行复制。
归档时间: |
|
查看次数: |
12654 次 |
最近记录: |