Delete Key in LookInFolders VS 2008 - 9.0 using MsBuild

懵懂的女人 提交于 2019-12-12 04:26:30

问题


I use MsBuild to Registry a VS Addin.

I need implement target Uninstall in MSBuild.

How can I delete my addin path in SOFTWARE\Microsoft\VisualStudio\9.0\AutomationOptions\LookInFolders registry using MsBuild ?

For install, I use

    <Target Name="RegistryExtensions">

            <Message Text="Registry AddIn..."></Message>
            <Registry.Set
                RegistryHive="LocalMachine"
                Key="SOFTWARE\Microsoft\VisualStudio\9.0\AutomationOptions\LookInFolders"
                Value="$(ProgramFiles)\LifeCycle\AddIns"
                DataType="String" />

            <Message Text="Adding LifeCycle.targets to VisualStudio SafeImports ..."></Message>
            <Registry.Set
                RegistryHive="LocalMachine"
                Key="SOFTWARE\Microsoft\VisualStudio\9.0\MSBuild\SafeImports"
                Value="MyLifeCycle"
                DataType="String"
                Data="$(MSBuildExtensionsPath)\LifeCycle.targets" ContinueOnError="true">
            </Registry.Set>
        </Target>

    <Target Name="UnRegistryAddin">
<!-- TODO -->
        </Target>

I try get the value, but I get Empty string

    <Registry.GetKey
        RegistryHive="LocalMachine"
        Key="SOFTWARE\Microsoft\VisualStudio\9.0\AutomationOptions\LookInFolders"
        Value="$(ProgramFiles)\LifeCycle\AddIns">
        <Output TaskParameter="Data" PropertyName="Addin1"/>
    </Registry.GetKey>

    <Message Text=" Addin1 $(Addin1)" />

回答1:


You can sue DeleteKey/DeleteKeyTree Registry tasks, see MSBuild Extension Pack help

<!-- Delete a key -->
        <MSBuild.ExtensionPack.Computer.Registry 
           TaskAction="DeleteKey" 
           RegistryHive="LocalMachine" 
           Key="SOFTWARE\ANewTemp"/>

I believe it should work with the syntax you are used for the Set task:

<Registry.DeleteKey ...

Important (required attributes to be set):

  • DeleteKey (Required: RegistryHive, Key)
  • DeleteKeyTree (Required: RegistryHive, Key)


来源:https://stackoverflow.com/questions/7686660/delete-key-in-lookinfolders-vs-2008-9-0-using-msbuild

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!