vs2013 warning MSB8012 的问题解决

警告提示信息为

warning MSB8012: TargetPath(D:\work\code\xxxx\Debug\xxxx.exe) does not match the Linker's OutputFile property value (c:\ccc\xxxx.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

这个问题通常是由于项目的设置引起的

修改 项目属性->常规->输出目录   与 链接器->常规->输出文件 保持一致即可。


重点来了,场景二,如果你要编译生成到指定目录然后(配置输出目录),启动调试,在(DEBUG下)也出现这个警告是因为什么呢?

经本人测试,应该算是vs2013的bug!

在debug中修改了输出目录后,VS2013IDE会去修改 项目.vcxproj 文件,增加输出目录的个性化配置,但是这段配置代码加在了vcxproj文件中的靠末尾部分,程序在编译时并未读取到这个配置信息,解决办法是把这段代码手动的插入到更靠前的部分去,本人将它提到
1   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
2     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
3   </ImportGroup>
之后,
便成
 1   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 2     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 3   </ImportGroup>
 4   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 5     <LinkIncremental>true</LinkIncremental>
 6     <OutDir>c:\ccc\</OutDir>
 7   </PropertyGroup>
 8   <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 9     <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
10   </ImportGroup>
再编译就不会出现警告了。
以下是关键配置代码

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
    <LinkIncremental>true</LinkIncremental>
    <OutDir>c:\ccc\</OutDir>
  </PropertyGroup>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值