简体   繁体   中英

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).

The addin works fine with vs 2010. Now the requirement is to make it compatible with vs 2012 (and possibly for future version).

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. Researching a bit reveals that the references (assemblies, Microsoft.visualstudio.Teamfoundation.*.dll s) for VS 2012 are compiled in .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.

So now I have two projects with same source code but with different target framework & VS version.

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. A wix project is now added to each solution and the MSI is working fine. 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). Then in the XML of your project file add your references based on the configuration.

<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. More info regarding conditional constructs can be found on MSDN .

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