Fody: Fody.WeavingTask task fails unexpectedly (due to missing directory)
I am using Fody v3.3.3 with the PropertyChanged.Fody v2.6 weaver and I often get the MSB4018 error during build in Fody\build\Fody.targets(32,5). It shows the following stack-trace:
The "Fody.WeavingTask" task failed unexpectedly.
System.IO.DirectoryNotFoundException: Could not find a part of the path '...\MyAmazingProject\obj\Debug\'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
at System.IO.File.WriteAllLines(String path, IEnumerable`1 contents)
at Fody.WeavingTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
When I check the directory does exist and when I build the failing project again, then sometimes it works. It’s quite random, but I have never seen this with v3.2.10.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 31 (17 by maintainers)
Commits related to this issue
- Add some logging to narrow down #629 — committed to tom-englert/Fody by tom-englert 6 years ago
- Add some logging to narrow down #629 (#635) — committed to Fody/Fody by tom-englert 6 years ago
I unexpectedly got this error while looking into another issue, and I can’t explain the behavior I see:
This happens on the first build of https://github.com/jakubsuchybio/fody-costura-build-repro in an isolated environment (separate
globalPackagesFolderinnuget.config).IntermediateCopyLocalFilesCacheis supposed to be set to$(IntermediateOutputPath)$(FodyCopyLocalFilesCache)but$(FodyCopyLocalFilesCache)ends up blank. The target gets a directory path but it expects a file path, and it goes boom 💥 .It seems that the
<PropertyGroup>inFody.targetswas ignored (the Fody properties are clearly not set, as if the MSBuild evaluation phase was skipped), but the task is still called somehow, and it requires theFodyAssemblyproperty to be set in order to be located in the first place.If you restart VS then everything works fine afterwards. Also, everything works fine in the first place if you compile from the command line. This leads me to believe it’s a VS caching quirk, but has anyone experienced this kind of behavior before?
Here’s the VS binary build log: dir-not-found.zip
can u try version 4.0.1