Deploying .NET components (upgrade the component for only a single client application)
I use Visual Studio .NET to create a component that will be shared by two client applications. Eventually, I plan to deploy new version of this component. However, not all of the new versions will be compatible with both client applications. When I deploy component and the client applications, I must ensure that I can up开发者_如何学Cgrade the component for a single client application. I must also minimize the need for configuration changes when I deploy new version of the component. What are possible ways to achieve this goal?
Your options are limited.
If you just link against the component, then both applications will use the latest version when it's released.
If you link against a specific version of the component you'll solve the problem of breaking changes, but it will mean that you have to update the configuration of the applications to link against the newer version when applicable.
I think you need to address why you'll be introducing breaking changes to your component.
If you are deploying to the Global Assembly Cache, just make sure to specify a different AssemblyVersion for each version of the assembly then you can install them side by side. Applications built against version 1 will continue to run against version 1, and applications built against version 2 will continue to run against version 2. You can redirect an individual application using the <bindingRedirect>
configuration element. (A publisher policy would affect all applications so you'll need to make changes to the app.config.)
If you are not using the GAC and are instead deploying the DLL to the same directory as the EXE you don't need to worry about side-by-side versioning. If you cannot rebuild the EXE against the newer DLL, then you need to specify the redirection as described above.
If all this sounds confusing, you're right. If possible, I would look into using ClickOnce to deploy your applications which makes the process of deploying updates trivial. ClickOnce deployed applications are not installed to the GAC and automatically check for updates based on a policy you define.
Best way is probably to just set up build symbols and use #ifdef App1 and #ifdef App2 to enable or disable pieces of code... Means you don't have to manage multiple projects or branches or anything similar... Assuming the code-bases will remain relatively similar, its the least hassle to accomplish what you want
精彩评论