https://social.msdn.microsoft.com/Forums/vstudio/en-US/5e3e21ca-c9e6-494f-8b57-51158b6db0f6/any-fix-for-the-msb3491-could-not-write-lines-to-file?forum=msbuild

How do i fix the error MSB3491    Could not write lines to file “D:\code\..\tools\optimized\obj811\amd64\Tools\Tools.tlog\Tools.lastbuildstate”. Could not find a part of the path ‘D:\some-path\tools\optimized\obj811\amd64\Tools\Tools.tlog\Tools.lastbuildstate’ ?

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets    312

Indeed Tools.tlog does not exist.

Solution:

It looks it works after moving the import tags at the end of the project file.

Can anyone explain the trick? I mention i have migrated the project from VS2012 to VS2015 ……

That is,

...
  <Target Name="PrepareForBuild">
     <Message Text="-------------------------------------------------------------------------------">
     </Message>
     <Message Text="Make sure directory $(TOOLSOBJDIR)$(ProjectName)\ exist">
     </Message>
     <Message Text="-------------------------------------------------------------------------------">
     </Message>
     <MakeDir Condition="!Exists('$(TOOLSOBJDIR)$(ProjectName)')" Directories="$(TOOLSOBJDIR)$(ProjectName)\" />
   </Target>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
...

Also, related
We’ve discovered that the cl.*.tlog files often have stale/bad information for our C++ project.

Reading this post: http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/ad60465d-fd89-4351-a749-4b4e9ab499d0 led me to add this XML at the top of all my vcxproj files:

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

 <PropertyGroup>

 <TrackFileAccess>false</TrackFileAccess>

 </PropertyGroup>

Yes, you can add

<TrackFileAccess>false</TrackFileAccess>

to turn off the TrackFileAccess.

As a result, no output file/intermediate file information will be write down to

link.read.1.tlog
link.write.1.tlog
CL.read.1.tlog

which makes VCBuild doesn’t know if the output files exists.

Advertisements
This entry was posted in develop and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s