Denis Kralj
Denis Kralj

Reputation: 633

Create vsix package from a class library

I have a project that was created as a class library. This library contains numerous controls that can be used in windows forms applications. Right now I want to create an installation package (*.vsix) that will embed these controls into the visual studio toolbox window. I also have a project that is filled with Web controls, but at this moment I want to concentrate on the Win controls part of the task.

The controls are visible in the toolbox window when I'm in the solution that has this project within itself.

I have created a vsix project and referenced the component project's dll as a Microsoft.VisualStudio.Assembly asset. The build process creates the vsix file that I require. When I run it on a system with a fresh VS installation, it goes through the install process with no problems, but the components don't show up in the toolbox.

When I try to register the asset as a Microsoft.VisualStudio.ToolboxControl I get the error 'The target "PkgdefProjectOutputGroup" does not exist in the project.'. The info i found on google didn't help me.

I am not sure what the problem is here. I might have missed a few steps but I don't know what exactly.

I have also found articles talking about WiX toolset to create packages, but I'm not sure if this is the thing that I am looking for.

EDIT: I found out what gave me the 'The target "PkgdefProjectOutputGroup" does not exist in the project.' message, it was me not giving a value for "Embed in this folder" textbox in the asset window. Build passes but the components still aren't visible in VS.

EDIT 2: After a few days of tinkering I'm still not able to create a package for the controls. I have used this article as my main reference along with a handful of other ones and nothing seems to do the trick.

I tried Using the TCI installer app that was provided as a sample. I first used it on the sample control and it worked flawlessly, but using it on my own library yielded no results. I have added a sample control to my own library just to check if I might be going crazy but the control still didn't show up in the toolbox. The control that I added can't be any simpler:

[ToolboxBitmap(typeof(IdiotControl))]
[ToolboxItem(true)]
public partial class IdiotControl : UserControl
{
    public IdiotControl()
    {
        InitializeComponent();
    }
}

Again when I want to add the controls from the dll manually (right-click on toolbox tab -> choose items -> browse for dll) the controls show up and I can drag and drop them on to the form but that's not acceptable to me.

I have also found the installation location in C:\Users\John\AppData\Local\Microsoft\VisualStudio\11.0\Extensions\doeehng3.0ko (that last part is probably randomly generated) and all the files are where they should be, still no controls in the toolbox (adding them manually from this location also works).

Upvotes: 4

Views: 1513

Answers (3)

I had this issue with VSIX as well. I have added a "Microsoft.VisualStudio.VsPackage" asset to source.extension.vsixmanifest that resides in a referenced project. The wizard then set the reference in the .csproj as follows:

    <ProjectReference Include="..\MyPackage\MyPackage.csproj">
      <Project>{2a4c3a07-c21d-48a4-a2e2-d74c09b554d7}</Project>
      <Name>MyPackage</Name>
      <IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3bPkgdefProjectOutputGroup%3b</IncludeOutputGroupsInVSIX>
      <IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly>
    </ProjectReference>

Then I changed my mind, but the IncludeOutputGroupsInVSIX and IncludeOutputGroupsInVSIXLocalOnly were left silently and this caused the error. Removing these properties from the project reference has solved the issue.

Upvotes: 0

Hans Karlsen
Hans Karlsen

Reputation: 2435

Had this issue in VS2022, VSIX - the solution was to add this row to the projects that reports missing target:

<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

(The target is automatically added to the VSIX project - but when you import other projects and mark them as assets in the VSIX those projects does not have the above target - hence the error)

Upvotes: 0

geektainment
geektainment

Reputation: 11

After spending 2 days, finally I am able to resolve the below error which came while adding reference of DLL application to VSIX project for Visual C++:

The target "PkgdefProjectOutputGroup" does not exist in the project.

Just open Project file .csproj or .vcxproj of DLL application which you are adding as a reference to VSIX project and edit below lines in the end:

Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.Cpp.targets"

Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"

Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.Cpp.Overrides.targets

Then build the VSIX project, this error should be resolved.

Upvotes: 1

Related Questions