简体   繁体   中英

.Net core 6: How to have output directory without assemblies

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.

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 )

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM