SharePoint 功能:如何使用通配符程序集版本控制? [英] SharePoint features: How can I use wildcard assembly versioning?

查看:12
本文介绍了SharePoint 功能:如何使用通配符程序集版本控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这可能是一个通用的 .NET 程序集加载问题,但在我的特定情况下,我希望我的 SharePoint 功能指向一个程序集,其版本控制与正确的 SVN 修订号相关联.

I think this is likely to be a generic .NET assembly loading question, but in my specific case, I want my SharePoint Features to point to an assembly whose versioning is associated with the correct SVN revision number.

我的程序集现在已按照 这篇文章.我希望能够仅将我的 SharePoint 功能配置为使用 GAC 中最新版本的程序集.

My assemblies are now versioned as mentioned in this article. I'd like to be able to just configure my SharePoint features to use the latest version of the assembly that's in the GAC.

<Feature Id="7b5d86e8-17dc-4943-8f4e-ad1068daf4f9" 
         Title="My happy feature" 
         Scope="Web" 
         Version="1.0.0.0" 
         Hidden="FALSE" 
         DefaultResourceFile="core" 
         ReceiverAssembly="HappyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772fbab82fe6896"
         ReceiverClass="HappyFeature.Receivers.HappyItemEventReceiver"
         xmlns="http://schemas.microsoft.com/sharepoint/">
</Feature>

当我这样做时,SharePoint 当然找不到程序集,因为强名称与此处描述的 1.0.0.0 版本不匹配.我的程序集中的当前版本是 1.0.4479.26553,所以我希望我的功能能够自动找到类似编号的程序集版本.我该怎么做?

When I do this, SharePoint of course cannot find the assembly because the strong name doesn't match up with the 1.0.0.0 version described in here. My current version in my assembly is 1.0.4479.26553, so I'd like my features to be able to automagically find similarly numbered assembly versions. How can I do this?

我有点天真地尝试了这样的事情:

I somewhat naively tried something like this:

ReceiverAssembly="HappyFeature, Version=1.0.*, Culture=neutral, PublicKeyToken=d772fbab82fe6896"

ReceiverAssembly="HappyFeature, Version=1.0.*.*, Culture=neutral, PublicKeyToken=d772fbab82fe6896"

但是当我尝试这样部署我的解决方案时,它似乎仍在寻找具有 1.0.0.0 版本的文件:

But when I try to deploy my solution as such, it still seems to be looking for a file with the 1.0.0.0 version:

功能'7b5d86e8-17dc-4943-8f4e-ad1068daf4f9'无法安装,因为加载事件接收器组件HappyFeature,版本=1.0..,文化=中立,PublicKeyToken=d772fbab82fe6896"失败的:System.IO.FileNotFoundException:可以不加载文件或程序集'HappyFeature,版本=1.0.0.0,文化=中立,PublicKeyToken=d772fbab82fe6896' 或它的依赖项之一.系统找不到指定的文件.文件name: 'HappyFeature, 版本=1.0.0.0,文化=中立,PublicKeyToken=d772fbab82fe6896'

Feature '7b5d86e8-17dc-4943-8f4e-ad1068daf4f9' could not be installed because the loading of event receiver assembly "HappyFeature, Version=1.0.., Culture=neutral, PublicKeyToken=d772fbab82fe6896" failed: System.IO.FileNotFoundException: Could not load file or assembly 'HappyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772fbab82fe6896' or one of its dependencies. The system cannot find the file specified. File name: 'HappyFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d772fbab82fe6896'

强制框架加载我的增量版本功能程序集的正确方法是什么?

What's the proper way to coerce the framework to load my incremented-version feature assemblies?

因此,虽然我实际上并没有解决我提出的具体问题,但 Ryan 的建议解决了我的实际问题,即只能使用 SVN 相关信息标记我的程序集,同时保留成功加载我的程序集的能力在 SharePoint FeatureReceiver 世界中.

So, while I didn't actually solve the specific question I'd asked, Ryan's suggestion solved my practical problem of just being able to tag my assemblies with SVN-related information while retaining the ability to successfully load my assemblies in the SharePoint FeatureReceiver world.

推荐答案

你可以做的是保持 AssemblyVersion 相同(至少当它是一个兼容的主要版本"时)但使用相同的技术来放置 SVN 修订号进入 AssemblyFileVersion 属性.

What you could do is keep the AssemblyVersion the same (at least whilst its a 'compatible major version') but use the same technique to put the SVN revision number into the AssemblyFileVersion property.

这样您就不必不断更新发布商政策文件.

Then you won't have to keep updating Publisher Policy files.

KB556041 - 如何使用程序集版本和程序集文件版本

假设您正在为您的项目构建一个框架程序集,许多开发人员在构建应用程序程序集时都会使用该程序集.如果您非常频繁地发布新版本的程序集......并且如果程序集具有强名称,则开发人员每次发布新程序集时都必须更改引用......在这种封闭组和易变场景中更好的选择是修复'Assembly Version' 并只更改'Assembly File Version'.

SO - AssemblyVersion 和 AssemblyFileVersion 之间有什么区别

这篇关于SharePoint 功能:如何使用通配符程序集版本控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆