Skip to content

NetOfficeFw.Build on a clean project fails because it can't locate a .DLL from my project #436

@chadknudson

Description

@chadknudson

I recently had to split my solution apart because our solution was exceeding the size for an Azure DevOps build pipeline. My COM AddIn for Word was moved to a new, smaller solution. When I tried to build that new solution, the NetOfficeFW.Build build task for Cleaning the COM AddIn from the registry was running and throwing an error that one of the other .DLLs from my project wasn't found. This error didn't happen before when this project was in my large solution, so I don't know quite what I did wrong when moving it to the smaller solution.

I resolved this by wrapping the NetOfficeFw.Build.targets import in a custom MSBuild property check that only includes the target if the expected DLL already exists. I did this by defining a custom condition based on file existence of the target COM AddIn DLL:

<PropertyGroup>
  <NetOfficeBuildEnabled Condition="Exists('bin\\$(Configuration)\\MyCOMAddIn.dll')">true</NetOfficeBuildEnabled>
</PropertyGroup>

I then wrap the Import of NetOfficeFw.Build.targets with that condition:

<Import Project="..\..\..\packages\NetOfficeFw.Build.2.1.0\build\NetOfficeFw.Build.targets"
        Condition="Exists('..\..\..\packages\NetOfficeFw.Build.2.1.0\build\NetOfficeFw.Build.targets') and '$(NetOfficeBuildEnabled)' == 'true'" />

I didn't need to do this in my old solution. I'm not sure where I messed things up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions