简体   繁体   English

从类库创建 vsix 包

[英]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.该库包含许多可在 Windows 窗体应用程序中使用的控件。 Right now I want to create an installation package (*.vsix) that will embed these controls into the visual studio toolbox window.现在我想创建一个安装包 (*.vsix),它将这些控件嵌入到 Visual Studio 工具箱窗口中。 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.我还有一个项目,里面装满了 Web 控件,但此时我想专注于任务的 Win 控件部分。

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.我创建了一个 vsix 项目并将组件项目的 dll 引用为Microsoft.VisualStudio.Assembly资产。 The build process creates the vsix file that I require.构建过程会创建我需要的 vsix 文件。 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.当我在具有全新 VS 安装的系统上运行它时,它通过安装过程没有问题,但组件没有显示在工具箱中。

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.'当我尝试将资产注册为Microsoft.VisualStudio.ToolboxControl ,出现错误'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.我还发现了一些关于创建包的 WiX 工具集的文章,但我不确定这是否是我正在寻找的东西。

EDIT : I found out what gave me the 'The target "PkgdefProjectOutputGroup" does not exist in the project.'编辑:我发现是什么给了我'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.构建通过,但组件在 VS 中仍然不可见。

EDIT 2 : After a few days of tinkering I'm still not able to create a package for the controls.编辑 2 :经过几天的修补,我仍然无法为控件创建包。 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.我尝试使用作为示例提供的 TCI 安装程序应用程序。 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.再次,当我想手动从 dll 添加控件时(右键单击工具箱选项卡 -> 选择项目 -> 浏览 dll)控件显示,我可以将它们拖放到表单上,但这对我来说是不可接受的.

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).我还在C:\\Users\\John\\AppData\\Local\\Microsoft\\VisualStudio\\11.0\\Extensions\\doeehng3.0ko找到了安装位置(最后一部分可能是随机生成的)并且所有文件都在它们应该在的地方,仍然工具箱中没有控件(从这个位置手动添加它们也有效)。

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++: 花了2天后,最终我能够解决在向Visual C ++的VSIX项目添加DLL应用程序引用时出现的以下错误:

The target "PkgdefProjectOutputGroup" does not exist in the project. 项目中不存在目标“PkgdefProjectOutputGroup”。

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: 只需打开DLL应用程序的项目文件.csproj.vcxproj ,您将添加它作为对VSIX项目的引用,并在最后编辑以下行:

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. 然后构建VSIX项目,应该解决这个错误。

Had this issue in VS2022, VSIX - the solution was to add this row to the projects that reports missing target:在 VS2022、VSIX 中存在此问题 - 解决方案是将此行添加到报告缺少目标的项目中:

<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) (目标会自动添加到 VSIX 项目中 - 但是当您导入其他项目并将它们标记为 VSIX 中的资产时,这些项目没有上述目标 - 因此出现错误)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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