none
VS2010 warning MSB8012 RRS feed

  • Question

  • I made a new project in VS2010. By default the linker places the resulting file in c:\Test\Release\test.exe but I want to change that to c:\Test\test123.exe

    What is the correct way to do this?

     

    When I do it "my old way" I get warnings I want to get rid of.  "My old way": Open project property pages and change Linker.General.Output File from $(OutDir)$(TargetName)$(TargetExt) to c:\Test\Test123.exe

    This results in the following warnings:
    1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(c:\test\Release\test.exe) does not match the Linker's OutputFile property value (c:\test\test123.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).
    1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(test) does not match the Linker's OutputFile property value (test123). 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).

    Thursday, April 29, 2010 8:34 AM

Answers

  • Hello Gaute,

    The warning throws out because that the output you specified doesn't match the predefined property($(OutDir), $(TargetName) and $(TargetExt)). Please check the target file under %ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets, you will set the DoLinkOutputFilesMatch target has the following tasks, which will check the Full path of output, file name and file extension.

     <Target Name="DoLinkOutputFilesMatch" Condition="'@(Link)' != ''">
        <ItemGroup>
          <_OutputFileFromLink Include="%(Link.OutputFile)" />
        </ItemGroup>
        <VCMessage Condition="'%(_OutputFileFromLink.FullPath)' != '$([System.IO.Path]::GetFullPath($(TargetPath)))'" Code="MSB8012" Type="Warning" Arguments="TargetPath;$(TargetPath);Linker;%(_OutputFileFromLink.FullPath);Link"/>
        <VCMessage Condition="'%(_OutputFileFromLink.Extension)' != '$(TargetExt)'" Code="MSB8012" Type="Warning" Arguments="TargetExt;$(TargetExt);Linker;%(_OutputFileFromLink.Extension);Link"/>
        <VCMessage Condition="'%(_OutputFileFromLink.Filename)' != '$(TargetName)'" Code="MSB8012" Type="Warning" Arguments="TargetName;$(TargetName);Linker;%(_OutputFileFromLink.Filename);Link"/>
      </Target>

    Also, someone has report this on our connect portal, you can vote here:
    https://connect.microsoft.com/VisualStudio/feedback/details/501237/relative-output-directory-leads-to-wrong-warning-msb8012?wa=wsignin1.0

    Regards,
    Rong-Chun Zhang
    MSDN Subscriber Supportin Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, April 29, 2010 10:19 AM
  • You can also take a look of this blog on the reasoning behind this warning:

    http://blogs.msdn.com/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx

        Linker output directory

    One of the warnings you may see when upgrading you applications is MSB8012: $(TargetPath) and Linker’s OutputFile property value does not match:

    - MSB8012: $(TargetExt) ('.dll') does not match the Linker's OutputFile property value 'C:\foo\Debug\MFCActiveX.ocx' ('.ocx') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetExt) property value matches the value specified in %(Link.OutputFile).

    - MSB8012: $(TargetPath) ('C:\foo\Debug\MFCActiveX.dll') does not match the Linker's OutputFile property value 'C:\foo\Debug\MFCActiveX.ocx' ('C:\foo\Debug\MFCActiveX.ocx') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetPath) property value matches the value specified in %(Link.OutputFile).

    Link.OutputFile is the value defined at Linker -> General -> Output File on the property page. By default, its value is $(OutDir)$(TargetName)$(TargetExt), which is the same as the value of $(TargetPath). When we convert an application from a previous version, however, there is not an easy way for conversion to parse Link.OutputFile to figure out what exactly the values are for $(TargetName) and $(TargetExt), as different customers may have formatted them in different ways. To work around that, we decided to preserve the value of Linker.OutputFile during conversion. After conversion, $(TargetName) will default to $(ProjectName). $(TargetExt) will default to the default extension for the application type: .dll for Dynamic Library, .lib for Static Library and .exe for Application. Link.OutputFile value will be preserved. Warning MSB8012 will be issued in the conversion log if Link.OutputFile and $(TargetPath) are not the same. You will get the same warnings when building the application.

    $(OutDir), $(TargetName) and $(TargetExt) are exposed on the "General" property page, as "Output Directory", "Target Name", "Target Extension", respectively. You can manually change the values of these properties so that you no longer get the warning.

    -If your project produces Import Library (Linker -> Advanced -> Import Library), you may need to change the Output folder of the Import Library as well after conversion if the Linker output directory is not the default output directory. Otherwise, the generated import lib maybe in a different directory than the linker output.

    -Debugging.Command is set to default $(TargetPath) after conversion. You may need to make changes so that the right executable will be launched upon F5 (Debugging) or Ctrl + F5 (Start without debugging).

    Li Shao, MSFT


    Li Shao
    Thursday, April 29, 2010 5:06 PM

All replies

  • Hello Gaute,

    The warning throws out because that the output you specified doesn't match the predefined property($(OutDir), $(TargetName) and $(TargetExt)). Please check the target file under %ProgramFiles%\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets, you will set the DoLinkOutputFilesMatch target has the following tasks, which will check the Full path of output, file name and file extension.

     <Target Name="DoLinkOutputFilesMatch" Condition="'@(Link)' != ''">
        <ItemGroup>
          <_OutputFileFromLink Include="%(Link.OutputFile)" />
        </ItemGroup>
        <VCMessage Condition="'%(_OutputFileFromLink.FullPath)' != '$([System.IO.Path]::GetFullPath($(TargetPath)))'" Code="MSB8012" Type="Warning" Arguments="TargetPath;$(TargetPath);Linker;%(_OutputFileFromLink.FullPath);Link"/>
        <VCMessage Condition="'%(_OutputFileFromLink.Extension)' != '$(TargetExt)'" Code="MSB8012" Type="Warning" Arguments="TargetExt;$(TargetExt);Linker;%(_OutputFileFromLink.Extension);Link"/>
        <VCMessage Condition="'%(_OutputFileFromLink.Filename)' != '$(TargetName)'" Code="MSB8012" Type="Warning" Arguments="TargetName;$(TargetName);Linker;%(_OutputFileFromLink.Filename);Link"/>
      </Target>

    Also, someone has report this on our connect portal, you can vote here:
    https://connect.microsoft.com/VisualStudio/feedback/details/501237/relative-output-directory-leads-to-wrong-warning-msb8012?wa=wsignin1.0

    Regards,
    Rong-Chun Zhang
    MSDN Subscriber Supportin Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, April 29, 2010 10:19 AM
  • You can also take a look of this blog on the reasoning behind this warning:

    http://blogs.msdn.com/vcblog/archive/2010/03/02/visual-studio-2010-c-project-upgrade-guide.aspx

        Linker output directory

    One of the warnings you may see when upgrading you applications is MSB8012: $(TargetPath) and Linker’s OutputFile property value does not match:

    - MSB8012: $(TargetExt) ('.dll') does not match the Linker's OutputFile property value 'C:\foo\Debug\MFCActiveX.ocx' ('.ocx') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetExt) property value matches the value specified in %(Link.OutputFile).

    - MSB8012: $(TargetPath) ('C:\foo\Debug\MFCActiveX.dll') does not match the Linker's OutputFile property value 'C:\foo\Debug\MFCActiveX.ocx' ('C:\foo\Debug\MFCActiveX.ocx') in project configuration 'Debug|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetPath) property value matches the value specified in %(Link.OutputFile).

    Link.OutputFile is the value defined at Linker -> General -> Output File on the property page. By default, its value is $(OutDir)$(TargetName)$(TargetExt), which is the same as the value of $(TargetPath). When we convert an application from a previous version, however, there is not an easy way for conversion to parse Link.OutputFile to figure out what exactly the values are for $(TargetName) and $(TargetExt), as different customers may have formatted them in different ways. To work around that, we decided to preserve the value of Linker.OutputFile during conversion. After conversion, $(TargetName) will default to $(ProjectName). $(TargetExt) will default to the default extension for the application type: .dll for Dynamic Library, .lib for Static Library and .exe for Application. Link.OutputFile value will be preserved. Warning MSB8012 will be issued in the conversion log if Link.OutputFile and $(TargetPath) are not the same. You will get the same warnings when building the application.

    $(OutDir), $(TargetName) and $(TargetExt) are exposed on the "General" property page, as "Output Directory", "Target Name", "Target Extension", respectively. You can manually change the values of these properties so that you no longer get the warning.

    -If your project produces Import Library (Linker -> Advanced -> Import Library), you may need to change the Output folder of the Import Library as well after conversion if the Linker output directory is not the default output directory. Otherwise, the generated import lib maybe in a different directory than the linker output.

    -Debugging.Command is set to default $(TargetPath) after conversion. You may need to make changes so that the right executable will be launched upon F5 (Debugging) or Ctrl + F5 (Start without debugging).

    Li Shao, MSFT


    Li Shao
    Thursday, April 29, 2010 5:06 PM
  • Thank you both for explaining.  It seems like there is no easy "correct way" to do what I want without getting warnings.
    Friday, April 30, 2010 12:55 PM
  • Gaute,

    I had a similar problem.  I tried to change the directory where the output file would be saved by changing the value of Output File from $(OutDir)$(TargetName)$(TargetExt) to something else.  That gave a MSB8012 warning.  Since I was just trying to change the directory of the output file, I changed instead the Output Directory property found on the General pane.  This in effects changes the value of $(OutDir).  Problem solved!

    Jean-Luc


    • Proposed as answer by fatchance Friday, June 3, 2011 2:23 PM
    Monday, December 6, 2010 7:15 PM
  • I solved a similar problem as follows (at least with VS2010 Pro Version 10.0.30319.1 RTMRel) because Rong-Chun's "solution" doesn't work.

    1) Open solution's Property Pages

    2) Expand Configuration Properties

    3) Select General

    4) Select Output Directory

    5) If Configuration is Active(Debug) change .\Debug to ..\Debug 

    6) If Configuration is Active(Release) change .\Release to ..\Release 

    NOTE: May be MSFT can fix this in an update soon!!!


    victorbos
    Wednesday, January 19, 2011 6:47 PM
  • This "explanation" makes no sense to me whatsoever...I've been trying for one hour now to get my old 2008 project to build in the 2010 version, but to no avail... How many things do you allow the 2010 version to break in existing projects? 

    Thursday, July 28, 2011 8:04 PM