문제

I want to activate a feature with custom properties. It is easy to do in onet.xml by providing Properties:

<Feature ID=“78277796-98D9-4276-B7D2-E3374AAC43D8“>
      <Properties>
            <Property Key=“MyProperty1“ Value=“FALSE“ />
            <Property Key=“MyProperty2“ Value=“6ECFC841-7FFF-4E06-9D50-0678CC43696D“ />
            <Property Key=“MyProperty3“ Value=“TRUE“ />
            <Property Key=“MyProperty4“ Value=“Custom Data“/>
      </Properties>
</Feature>

In Code I have seen, we can use Reflection to specify custom properties and Yaroslavs remake. How could one specify custom properties when activating feature in powershell:

Enable-SPFeature ...
도움이 되었습니까?

해결책

It's not possible throught Enable-SPFeature if you need it you'll have to write your own cmdlet, there a guide for doing that here

In that cmdlet, you can use the reflection hack you linked to, but note that when you're using reflection to find non-public methods you run the risk of any update/hotfix/SP breaking your code.

다른 팁

It sounds like what you have is a configurable component. If that is the case, you should implement configuration properly instead of hacking/reflecting an object to make is suit your purpose.

The patterns & practices group discusses configuration in "The Application Setting Manager" section of their guidance. The guidance also includes sample code for a List-backed configuration store.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top