Home Dashboard Directory Help
Search

How to fix MSB8012 (Lib.OutputFile)? by BobH2


Status: 

Closed
 as Not Reproducible Help for as Not Reproducible


12
0
Sign in
to vote
Type: Bug
ID: 523864
Opened: 1/8/2010 2:00:11 AM
Access Restriction: Public
3
Workaround(s)
view
11
User(s) can reproduce this bug

Description

I am getting the following warning:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1095,5): warning MSB8012:
TargetPath(E:\Test\Lib10\Lib10.lib) does not match the Library's OutputFile property value (E:\Test\Lib10\x64\Release\Lib10.lib).
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 %(Lib.OutputFile).


I can see where to change $(OutDir), $(TargetName), and $(TargetExt).

I do not see where to change %(Lib.OutputFile) and with the "%" prefix I am assuming it is not a macro but probably a path under "Librarian", except I do not see a "OutputFile" variable. In fact, I do not see "E:\Test\Lib10\Lib10.lib" anywhere, including the Command Line summary.

When I hit [F1] on "MSB8012", I get a topic called "Output Window". In VS6, this would have brought up a help screen to explain the error.

Also, what's with "Librarian"? There's no librarian here. It's a dumb name. Someone needs to change the name to "Library" or "Linker" or "Library Linker".


I keep my *.libs in my project's root folder but modify the name for release and debug and want to append "x64" for the 64 bit modules and end up with the following:

Lib10.lib
Lib10D.lib
Lib10-x64.lib
Lib10D-x64.lib

I then proceeded to modify my output path a bit more and got the following messages:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1095,5): warning MSB8012: TargetPath(E:\Test\Lib10\Lib10.lib) does not match the Library's OutputFile property value (E:\Test\Lib10\Lib10-x64.lib).

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 %(Lib.OutputFile).


1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1097,5): warning MSB8012: TargetName(BPE_Lib10) does not match the Library's OutputFile property value (BPE_Lib10-x64).

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 %(Lib.OutputFile).


The Lib file was created in the folder and with the name I wanted.


THEN, I actually read and tried to understand the error, modified Configuration Properties | General | TargetName to "Lib10-x64", the messages disappeared, and the file was produced ok.
Details
Sign in to post a comment.
Posted by laduran on 2/20/2012 at 10:53 AM
@aao123

I think you need to relax man. Or find another line of work. If you've ever worked with Eclipse with Android, you would know things could be much, much worse than Visual Studio.
Posted by aao123 on 1/20/2011 at 12:31 PM
you people have some nerve :
"In this release we dont have that functionality " and "... we have now become more transparent"

You people broke the existing(and very very useful) functionality with your freaking transiency enhancements - verifying build output is time consuming enough without your useless enhancements. It is now up to a user to create the workaround, is that the attitude? What is next - build your own visual studio?
Posted by RocketRob on 10/13/2010 at 3:02 PM
This warning suddenly came up in my builds today... after never having seen this in the past. Did something change in the Windows Updates from last night (10/12/2010)? I have never modified the CPPBuild.targets files and really shouldn't have to do so!

I am getting these three warnings in EVERY C++ project I have. All of these projects were defined in VS2010 and are not upgrades from prior versions:

2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\CODE\MSXP\Debug\DBWizard.exe) does not match the Linker's OutputFile property value (). 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).
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.exe) does not match the Linker's OutputFile property value (). 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).
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(DBWizard) does not match the Linker's OutputFile property value (). 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).

How do I proceed?
Posted by BobH2 on 8/22/2010 at 11:26 AM
Here I go again.

I fixed the last projects by fiddling. This one does seem to fiddle. I've tried a few different things, here's the last scenario.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(E:\PROJECTFOLDER\PROJECTNAME\VS10\Debug\TARGETNAME.dll) does not match the Linker's OutputFile property value (d:\xxx\BIN\TARGETNAME.DLL). 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).

Settings
========
General | OutputDirectory:        .\Debug
General | IntermediateDirectory:    .\Debug
General | TargetName            $(ProjectName)    -> PROJECTNAME
Linker | General | Output File:        d:\xxx\BIN\TARGETNAME.DLL

I changed these from the VS6 conversion settings to:
General | OutputDirectory:        .\Debug        -> DEBUG
General | IntermediateDirectory:    .\Debug        -> DEBUG\

Macros was:
$(OutDir)    = .\Debug

And the macros are now:
$(OutDir)            = E:\PROJECTFOLDER\PROJECTNAME\VS10\DEBUG\
$(ProjectDir)    = E:\PROJECTFOLDER\PROJECTNAME\VS10\
$(TargetExt)    = .dll
$(TargetName)    = TARGETNAME
$(TargetPath)    = d:\Release\bin\TARGETNAME.DLL


The documentation states:

$(TargetName) The base name of the primary output file for the build.
$(TargetExt) The file extension of the primary output file for the build. It includes the '.' before the file extension.
$(TargetPath) The absolute path name of the primary output file for the build (defined as drive + path + base name + file extension).
$(OutDir) Path to the output file directory, relative to the project directory. This path should have a trailing slash. This resolves to the value for the Output Directory property.

The documentation is incomplete. "Primary Output File" is, I assume the end product of my compile and link. TargetName and TargetExt is, I hope just the filename and extension of the final output. And I would have assumed that the linker would create the file where I want it and with the name I want, just like in VS6.

I do not see/understand what the problem is here. So what do i do to fix this?

How do I compile and create debug and release intermediate files in one partition, but deposit the end result in a BIN folder in my release partition for testing and debugging, without getting warning messages?

Thanks, Bob.
Posted by BobH2 on 7/10/2010 at 12:56 PM
I have now installed the production version of Visual Studio 2010 and am still getting the same problem:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1151,5): warning MSB8012: TargetPath(E:\Test\Lib10\.\Debug\Lib10.lib) does not match the Library's OutputFile property value (E:\Test\Lib10\Lib10D.lib). 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 %(Lib.OutputFile).

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(1153,5): warning MSB8012: TargetName(Lib10) does not match the Library's OutputFile property value (Lib10D). 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 %(Lib.OutputFile).

I have no problem fixing this manually but where do I go? What do I do? Is there a help topic available yet?

It looks like the library is being created correctly, but I do not like warnings.

Thanks,
Bob.

Posted by Microsoft on 4/22/2010 at 12:34 PM
Hi Bob,

Thanks for reporting this issue. We are closing the bug, if you continue to see this issue after my last recommendation please feel free to reactivate the bug.

Thanks,
Amit Mohindra
Visual C++ Team
Posted by Microsoft on 2/18/2010 at 12:12 PM
Hi Bob,

About the original bug the warning is generated because in Visual Studio 2010 we have moved the C++ build system to be based on MSBuild. In earlier versions of Visual Studio when you changed the output file property the "TargetName" "TargetExt" properties were changed in background by the product itself. In this release we dont have that functionality and we have now become more transparent and warn the user to make sure that the output file property does match with the "OutDir" "TargetName" and "TargetExt" properties.

Your can change %(lib.outputfile) by going to project properties "Configuration Properties->Librarian->Output File".

Regarding your response copying final linked output should be achievable with VS2010. I think it might be a sideeffect of the warning that are getting generated during build.

Can you verify that is the case?

Thanks,
Amit Mohindra
Visual C++ Team
Posted by Microsoft on 1/17/2010 at 7:02 PM

Thank you for your feedback, We are currently reviewing the issue you have submitted.
Posted by BobH2 on 1/17/2010 at 7:22 AM
I am now getting to compiling and linking my first VS10 project that will use the library.

I keep all my source code on my "E\:" drive, including intermediate files etc. The *.LIB files that are linked into projects also reside on the "E:\" drive.

My final ouptut, that is files suchas *.DLLs and *.EXEs that released to customers get compiled to the "D:\" Drive. In this way, I have a clear set of source code folders that are backed up, and a clear set of customer release folders that are zipped up for customers, with no possibility of sending irrelevant or source code files to customers.

This is the way I have always done it with VS6.

VS10 looks like it is insisting that I produce my final linked file in the intermediate files path somehow. I should be able to just set the final path and file name in Configuration Properties | Linker | General | Output File.

Posted by BobH2 on 1/17/2010 at 3:59 AM
I have just uploaded the project settings.
Posted by Microsoft on 1/10/2010 at 9:31 PM
Thanks for reporting the issue.
In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Could you please attach a zipped project file to this feedback through our site to help us reproduce the issue?

Thanks again for your efforts and we look forward to hearing from you.
Visual Studio Product Team
Sign in to post a workaround.
Posted by gordon88 on 1/31/2013 at 3:39 PM
I have not heard of any simple solutions unless you agree to comply with VS rules;

Workaround; edit the build macro to remove this stupide test.
I hate that but it works. I haven't seen any side effect.

1) Go to directory of MsBuild macro
typically "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\"

2) make a backup of file Microsoft.CppBuild.targets (just in case!)

3) Edit file "Microsoft.CppBuild.targets"
(be carefull that you may need to change file security (allow User Write) if your text editor doesn't run as Administrator)

4) Search for the following statement (around line 990)
<VCMessage Condition="'%(_OutputFileFromLink.FullPath)' != '$([System.IO.Path]::GetFullPath($(TargetPath)))'" Code="MSB8012" Type="Warning" Arguments="TargetPath;$(TargetPath);Linker;%(_OutputFileFromLink.FullPath);Link"/>

5) Put it in comments ( add !-- at beginning and -- at end, .

< !-- VCMessage Condition="'%(_OutputFileFromLink.FullPath)' != '$([System.IO.Path]::GetFullPath($(TargetPath)))'" Code="MSB8012" Type="Warning" Arguments="TargetPath;$(TargetPath);Linker;%(_OutputFileFromLink.FullPath);Link"/-->

6) Save and use VS

The warning should now be gone.
Be careful not to mess up files of MSBuild (worst case you may have to re-install VS)
Good luck
Posted by marc375 on 9/16/2011 at 9:14 AM
In order not to have all the compiler/linker output go into the deployment directory, one possible solution is to keep all values to their defaults and add a post-build event (Property > Configuration Properties > Build Events > Post-Build Event) to simply copy the output file into its desired location (multiple lines are possible):
echo Copying "$(Outdir)$(TargetName)$(TargetExt)" to "C:\desired\location\" ...
copy "$(Outdir)$(TargetName)$(TargetExt)" "C:\desired\location\"
Posted by bob_r1970 on 4/15/2011 at 3:05 PM
So it is "Closed as Not Reproducible". Absurd. It is easily reproduced and not difficult to work around.

See the response by Li Shao at by http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/beb1c32f-3893-4061-81a7-4aed4032a367
He explains exactly what causes the "warning".

Short version:
In project properties:
    1) set Configuration Properties | Linker | General | Output file to $(OutDir)$(TargetName)$(TargetExt)
    2) set Configuration Properties | General | Output Directory to "desired directory path"
    3) set Configuration Properties | General | Target Name to "desired name for output file"
    4) set Configuration Properties | General | Target Extension to "desired output file extention (include dot)"

Replace the quoted items with the appropriate values.
File Name Submitted By Submitted On File Size  
FilerProjectSettings.zip (restricted) 1/17/2010 -