My project is a Visual Studio Extension. The solution contains multiple projects and references multiple NuGet packages. I am using visual studio 2019 version 16.2.1 and I am using Microsoft.VSSDK.BuildTools version 16.2.3073.
If I rebuild the complete project, or if I clean the solution before building, everything seems to be built correctly.
However, if I build the solution without cleaning it first, at least one dll is omitted from the VSIX installation. This specific DLL is the output of a second level project reference.
My top level VSIX project is MultiLanguageWPF. This has a project reference to MultiLanguageLegacy, which in turn has a project reference to MultiLangCodeParser. The file MultiLangCodeParser.dll is missing from the VSIX after a build.
MultiLanguageWPF
|
+-- MultiLanguageLegacy
|
+-- MultiLangCodeParser
The same problem occurs when I start the debugger using F5, unless I clean the project first (which is particularly annoying).
How can I prevent this different behavior for build and rebuild?
By the way, building my solution always builds the top level project MultiLanguageWPF, even if it has only just been built.
If I rebuild the complete project, or if I clean the solution before building, everything seems to be built correctly.
Yes, the solution builds well and it's expected behavior. See this, the rebuild is clean+build
, so both these two ways work correctly. No matter rebuild
or clean and build
, they will build exactly all projects in your solution.In this way, the MultiLangCodeParser.dll
can be recognized by MultiLanguageWPF and will contain it in vsix package.
However, if I build the solution without cleaning it first, at least one dll is omitted from the VSIX installation. This specific DLL is the output of a second level project reference.
If I change something in MultiLanguageWPF
project, now build the solution, since I haven't make any changes to MultiLanguageLegacy
and MultiLangCodeParser
, the VS won't actually build these two projects, it will only build the top-level MultiLanguageWPF
project itself, similar to this:
When vs only build the top-level project while not rebuilding the first and second level project, the build engine will only read content from MultiLanguageWPF.csproj, in this file it only defines the package reference to MultiLanguageLegacy
, so it will contain MultiLanguageLegacy.dll
in .vsix, but won't copy the MultiLangCodeParser.dll cause in this situation the build engine didn't know MultiLanguageLegacy.dll
depend on MultiLangCodeParser.dll
. It didn't read data from MultiLanguageLegacy.csproj and build it, so the engine won't know the dependency relationship between first level and second level projects if it only build the top-level project in my opinion.
Workaround:
I can reproduce the same issue and it do exist, the workaround for your current solution can be adding a script below into MultiLanguageWPF.csproj
: (Assuming your three projects are in same solution folder)
<Target Name="AddCustomItem" AfterTargets="GetVsixSourceItems">
<ItemGroup>
<VSIXSourceItem Include="..\MultiLangCodeParser\bin\$(Configuration)\MultiLangCodeParser.dll" />
</ItemGroup>
</Target>
Then this annoying issue seems to go away in my machine.