SharePoint 功能:如何使用通配符程序集版本控制?

发布于 2024-07-25 05:36:10 字数 1902 浏览 1 评论 0原文

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

我的程序集现在已按 这篇文章。 我希望能够配置我的 SharePoint 功能以使用 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,因此我希望我的功能能够自动找到类似编号的程序集版本。 我怎样才能做到这一点?

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

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

但是

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

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

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

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


编辑:所以,虽然我实际上没有解决我提出的具体问题,但 Ryan 的建议解决了我的实际问题,即能够使用 SVN 相关信息标记我的程序集,同时保留在 SharePoint 中成功加载我的程序集的能力特征接收器世界。

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.

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>

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"

and

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

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:

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?


EDIT: 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

望她远 2024-08-01 05:36:10

您可以做的就是保持 AssemblyVersion 相同(至少在其“兼容的主要版本”时),但使用相同的技术将 SVN 修订号放入 AssemblyFileVersion 属性中。

这样您就不必不断更新发布者策略文件。

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

假设您正在构建一个框架您的项目的程序集,许多开发人员在构建应用程序程序集时都会使用该程序集。 如果您非常频繁地发布新版本的程序集...并且如果程序集是强命名的,那么开发人员每次发布新程序集时都必须更改引用...在这种封闭组和易变的情况下,更好的选择是修复“程序集版本”并仅更改“程序集文件版本”。

SO - AssemblyVersion 和 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 - How to use Assembly Version and Assembly File Version

Suppose you are building a framework assembly for your project which is used by lot of developers while building the application assemblies. If you release new version of assembly very frequently ... and if assemblies are strong named, Developers will have to change the reference every time you release new assembly ... A better option in such closed group and volatile scenarios would be to fix the 'Assembly Version' and change only the 'Assembly File Version'.

SO - What are the differences between AssemblyVersion and AssemblyFileVersion

梦里°也失望 2024-08-01 05:36:10

您可以使用发布者策略重定向到新版本。

You can use a publisher policy to redirect to the new version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文