The convention for Fody addin NuGet packages is as follows:
📁 build
AddinName.Fody.props
📁 lib
📁 net452
AddinName.dll
AddinName.xml
📁 netstandard2.0
AddinName.dll
AddinName.xml
📁 weaver
AddinName.Fody.dll
AddinName.Fody.xcf
build/AddinName.Fody.props
: Facilitates addin discovery via an props file included by NuGet.lib
: Contains the Lib/Reference project for all supported target frameworks.weaver
: Contains the Weaver Project assembly. Also contains the XCF file to Supporting intellisense for FodyWeavers.xml.
The FodyPackaging NuGet Package simplifies following the above convention.
The below files are include as MSBuild props and targets in a package.
<Project>
<PropertyGroup>
<PackageId Condition="'$(PackageId)' == ''">$(MSBuildProjectName).Fody</PackageId>
<PackageTags Condition="'$(PackageTags)' == ''">ILWeaving, Fody, Cecil, AOP</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetsForTfmSpecificContentInPackage Condition="'$(SkipPackagingDefaultFiles)' != 'true'">$(TargetsForTfmSpecificContentInPackage);IncludeFodyFiles</TargetsForTfmSpecificContentInPackage>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<NoPackageAnalysis>true</NoPackageAnalysis>
<NoWarn>$(NoWarn);NU5118</NoWarn>
<DisableFody>true</DisableFody>
<WeaverDirPath Condition="'$(WeaverDirPath)' == ''">..\$(PackageId)\bin\$(Configuration)\</WeaverDirPath>
<WeaverPropsFile Condition="'$(WeaverPropsFile)' == ''">$(MSBuildThisFileDirectory)..\Weaver.props</WeaverPropsFile>
</PropertyGroup>
</Project>
<Project>
<Target Name="IncludeFodyFiles">
<PropertyGroup>
<WeaverFile>$(WeaverDirPath)\netstandard2.0\$(PackageId).dll</WeaverFile>
<XcfFile>$(WeaverDirPath)\netstandard2.0\$(PackageId).xcf</XcfFile>
</PropertyGroup>
<Error Text="FodyPackaging: No weaver found at $(WeaverFile). $(ProjectName) should have a Project Dependency on $(PackageId), and $(PackageId) should target 'netstandard2.0'."
Condition="!Exists($(WeaverFile))" />
<ItemGroup>
<TfmSpecificPackageFile Include="$(XcfFile)"
PackagePath="weaver\$(PackageId).xcf"
Condition="Exists($(XcfFile))" />
<TfmSpecificPackageFile Include="$(WeaverFile)"
PackagePath="weaver\$(PackageId).dll" />
<TfmSpecificPackageFile Include="$(WeaverPropsFile)"
PackagePath="build\$(PackageId).props" />
</ItemGroup>
</Target>
</Project>
Included in the consuming package to facilitate addin discovery.
<Project>
<ItemGroup>
<WeaverFiles Include="$(MsBuildThisFileDirectory)..\weaver\$(MSBuildThisFileName).dll" />
</ItemGroup>
</Project>