Skip to content

Latest commit

 

History

History
119 lines (89 loc) · 4.63 KB

addin-packaging.md

File metadata and controls

119 lines (89 loc) · 4.63 KB

Addin packaging

Convention

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

Convention Descriptions

FodyPackaging NuGet Package

The FodyPackaging NuGet Package simplifies following the above convention.

MSBuild props and targets

The below files are include as MSBuild props and targets in a package.

FodyPackaging.props

<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>

anchor

FodyPackaging.targets

<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>

anchor

Weaver.props

Included in the consuming package to facilitate addin discovery.

<Project>
  <ItemGroup>
    <WeaverFiles Include="$(MsBuildThisFileDirectory)..\weaver\$(MSBuildThisFileName).dll" />
  </ItemGroup>
</Project>

anchor