Unreferenced assemblies are not being published to IIS using WebDeploy

47 views Asked by At

I'm using the latest version of Visual Studio 2022 (17.3.0) to publish an ASPNET (NET6) webapp to IIS.

I use a plugin system for some of the assemblies and these are not referenced in the main project. I need these assemblies published, so I added the following post-build events:

xcopy "$(SolutionDir)pathtoassembly\bin\Debug\net6.0\assemblyname.dll" "$(TargetDir)" /Y
xcopy "$(SolutionDir)pathtoassembly\bin\Debug\net6.0\assemblyname.pdb" "$(TargetDir)" /Y

I do the above for a number of assemblies. But a couple of these are not being published. The build process does copy the files into the main project's bin folder.

The temporary publish folder (\obj\Debug\net6.0\win-x64\PubTmp\Out) does not contain these files so therefore they are not being published. All other unreferenced assemblies which I copy in the post-build event are successfully being published.

Is there a reason certain files do not get published?

1

There are 1 answers

0
Ivan-Mark Debono On

I was missing the following in the publish profile file:

<ItemGroup>
  <JobFiles Include="**\Plugins*">
    <Path>\Plugins</Path>
  </JobFiles>
</ItemGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
  <Copy SourceFiles="@(JobFiles)" DestinationFolder="$(PublishDir)\" SkipUnchangedFiles="false" />
</Target>

After adding the above, publishing works as expected.