I have already installed Fody in my application several and several times but still this error appears below, could anyone tell me why it happens? I use the latest version of Visual Studio and latest version of Framework
-
1Do you have both Fody and Costura.Fody referenced, assuming you are attempting to embed referenced assemblies as executable resources. – Ross Bush May 08 '19 at 20:46
-
yes, but even then the error appears, compiled several times and all appeared this – gbcga97 May 08 '19 at 20:59
-
Are all packages current, perhaps update solution package reference? – Ross Bush May 08 '19 at 21:04
-
Make sure the Build Action for FodyWeavers.xml is set to None. For some reason, it was set to Resource on my side, creating the same error, even if the file was there and with the correct content. – Alexandru Dicu Jul 30 '23 at 08:52
5 Answers
Sometimes (for unknown reason) FodyWeavers.xml
cannot be added automatically when the package is added. You'll need to add it to the root of the project manually:
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>
I'm using Fody 4.2.1
and Costura.Fody 3.3.3
I hope it helps

- 7,521
- 5
- 45
- 67
-
.NET projects can reference NuGet packages two ways, packages.config (PC) or PackageReference (PR). [PR does not support content files](https://learn.microsoft.com/en-us/nuget/reference/migrate-packages-config-to-package-reference#content-assets-are-not-available-when-the-package-is-installed-after-the-migration), which is how PC projects get files added to the project on package install. Maybe this is the "unknown" reason. – zivkan May 08 '19 at 23:33
-
@zivkan I'm pretty sure I was using "PC" way, but I can't say for sure, it was a couple years ago. But I do remember that creating a file was a solution... I'm curious to hear it fixes the issue. – Pavel Kovalev May 09 '19 at 00:09
-
I did this, system said, 'could not find file FodyWeavers.xsd' .... Where do I get that? – baye dbest Jan 02 '20 at 15:41
-
I had to remove and re-add the same package, the required files were added automatically (XML and xsd). – Mando Apr 08 '20 at 23:37
In my case, FodyWeavers.xml is already exists because the PropertyChanged.Fody library was installed. if this file exists, just add <Costura />
to it.
Before
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
After
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
<Costura />
</Weavers>

- 775
- 2
- 13
- 37
I had same issue on my Cake script using MSBuild command and I solved that:
a) Applying EgoistDeveloper above tip
b) Cleaning ./bin and ./obj folder of all projects under my solution folder
c) Adding -t:Clean,Restore,... msbuild parameter command line

- 775
- 2
- 13
- 37

- 21
- 1
-
Just part `b)` that is, `remove bin obj folders` was all I needed to do – Serj Sagan Oct 29 '21 at 21:25
In my case, I FodyWeavers.xml already existed. I cut the file out of the folder and pasted it back in, and the error went away.

- 21
- 1
In my case, one of the things that I did to fix this is that I updated the other package (Realm) which was using Fody as a transitive package. Now I no longer get the error.

- 353
- 3
- 12