0

I am porting company products in .Net core 6 from .Net 4.8. In the solution, there is an output directory containing: Assemblies, Configuration, Log, Resources directories and only .exe, .pdb and .exe.config of the launcher project. Dlls are in Assemblies directory and I absolutely need to replicate the same structure.

In launcher project .csproj file we have set:

<OutputPath>$(SolutionDir)\$(Configuration)</OutputPath>

In others:

<OutputPath>$(SolutionDir)\$(Configuration)\Assemblies</OutputPath>

During compilation, VS Studio Professional 2022 continues to copy .dlls/.pdbs of the ProjectReference included projects and recursively it copies all the .dlls more and less. In order to avoid this behavior, I have tried a lot of methods, such as using all these properties (also in different setting combinations: none, all, compile...) but the issue still happens:

<CopyLocalLockFileAssemblies>
<CopyLocal>
<CopyLocalSatelliteAssemblies>
<IncludeAssets>
<ExcludeAssets>
<PrivateAssets>
<AppendTargetFrameworkToOutputPath>

At the moment, I am building in windows but in the future there will also be some linux machines that have to build solutions, so I need a method that should work in all environments.

Is it possible to do it?

Loading of assemblies is not a problem, I have modified AssemblyLoadContext.Default.Resolving and if I manually delete dlls from the output directory, the application works but I need something more "elegant" than a delete script after building (Post-build event).

Domenico
  • 71
  • 1
  • 6

1 Answers1

0

When you mention "a delete script after building", was that implying one called using a Post-build event? I realize this is probably not exactly what you had in mind, as it will in effect be a script that is called after each time a project is built.

Still, it's not exactly the same as running a script manually, so if you are having trouble finding better options, this may be an alternative?

Open Properties for your project, and look for this:
(You may also want to have a look at the documentation for build evens)

enter image description here

Kjartan
  • 18,591
  • 15
  • 71
  • 96
  • Thank you for your help, unfortunately when I said "a delete script after building", I meant Post-build event. So I am looking for another solution, your suggestion was my last option. – Domenico Feb 03 '22 at 08:35