简体   繁体   English

在2010和2012年开发和部署Visual Studio插件

[英]Development and deployment of visual studio addin for 2010 & 2012

I have developed an addin for visual studio 2010, which performs custom task on TFS workitems (via button click & context menus). 我为Visual Studio 2010开发了一个插件,该插件在TFS工作项上执行自定义任务(通过按钮单击和上下文菜单)。

The addin works fine with vs 2010. Now the requirement is to make it compatible with vs 2012 (and possibly for future version). 该插件可与vs 2010很好地兼容。现在的要求是使其与vs 2012兼容(并可能与将来的版本兼容)。

Here are the references, 这里是参考,

tfs参考

The addin doesn't work in VS 2012. If I update the host value in .addin file and try to load it, the team explorer crashes / or the addin doesn't work. 该插件在VS 2012中不起作用。如果我更新.addin文件中的主机值并尝试加载它,则团队资源管理器将崩溃/或该插件不起作用。 Researching a bit reveals that the references (assemblies, Microsoft.visualstudio.Teamfoundation.*.dll s) for VS 2012 are compiled in .Net 4.5. 进行一些研究后发现,VS 2012的引用(程序集, Microsoft.visualstudio.Teamfoundation.*.dll )在.Net 4.5中进行了编译。

If I upgrade the solution, upgrade the references and set target framework to .NET 4.5, the addin works for VS 2012. However, as expected it doesn't work for VS 2010. 如果我升级解决方案,升级引用并将目标框架设置为.NET 4.5,则该插件适用于VS2012。但是,正如预期的那样,该插件不适用于VS 2010。

So now I have two projects with same source code but with different target framework & VS version. 所以现在我有两个项目,它们的源代码相同,但目标框架和VS版本不同。

The question is: 问题是:

How can I manage source code efficiently, I don't want to keep two set of source files. 如何有效地管理源代码,我不想保留两组源文件。 It will become hard to maintain in future. 将来将很难维护。

How to deploy them. 如何部署它们。 As VS 2012 doesn't support simple deployment, I used wix. 由于VS 2012不支持简单部署,因此我使用了wix。 A wix project is now added to each solution and the MSI is working fine. 现在,将wix项目添加到每个解决方案中,并且MSI运行正常。 But this will make two different installer. 但这将产生两个不同的安装程序。 How can I make it one installer for both version (and possibly future versions as well)? 如何使它成为两个版本(以及将来的版本)的一个安装程序?

Use one project and have conditional references based on project configuration. 使用一个项目,并根据项目配置获得条件引用。 In your project add new configurations (for example, TFS2010 and TFS2012). 在您的项目中添加新配置(例如TFS2010和TFS2012)。 Then in the XML of your project file add your references based on the configuration. 然后在您的项目文件的XML中添加基于配置的引用。

<Choose>
<When Condition="'$(Configuration)' == 'TFS2010'">
  <ItemGroup>
    <Reference Include="Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <Reference Include "... any other needed TFS references" />
  </ItemGroup>
</When>
<When Condition="'$(Configuration)' == 'TFS2012'">
  <ItemGroup>
    <Reference Include="Microsoft.TeamFoundation.Client, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <Reference Include "... any other needed TFS references" />
  </ItemGroup>
</When> 
</Choose>

When you change your configuration in Visual Studio the correct references will be loaded. 当您在Visual Studio中更改配置时,将加载正确的引用。 More info regarding conditional constructs can be found on MSDN . 有关条件构造的更多信息,请参见MSDN

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

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