1

まず第一に、これは解決された問題と非常によく似ています。カスタム アクションは、WiX 経由で使用される C# でエラー 1154 で失敗します。

ただし、自分の状況で問題を解決するための具体的な手順を特定できませんでした。うまくいけば、誰かが私を正しい方向に向けることができます。

私の場合、Wise Installation Studio 7.0 を使用して、Server 2008 R2 以降で .Net Framework 3.5 SP1 のサーバー マネージャー機能を開始するために作成した C# カスタム アクションを実行しています。

Visual Studio 2010 でカスタム アクションを標準の .Net 2.0 クラス ライブラリとして作成しました。

私の推測では、ここで何か違うことをする必要があります。これは、マネージ DLL 以外のものとしてコンパイルする必要があるということです。私が使用しているコードは非常に簡単です...他の誰かがサーバー 2008 R2 の .Net Framework 3.5 SP1 問題の解決策を投稿したフレクセラ フォーラムから取得したものです。

using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using Common_Functions;


namespace ActivateDotNetFramework
{
    /**
 * @brief helper library to activate .Net Framework on certain operating systems
 * 
 * @args None
 * 
 * 
 * @author Daniel Lee
 * @date Jan 17,2012
 * @version 1.0
 * @bug 6540 Role Management tool required for 2008R2 to install .NET 3.5 SP1
 **/
    class ActivateDotNetFramework
    {
        static void Main(string[] args)
        {

            string logFile = "ActivateDotNetFeatures.log";
            WriteToLog logWriter = null;
            Process p = null;            
            ProcessStartInfo startInfo = null;

            try
            {
                logWriter = new WriteToLog(logFile, "");
                logWriter.UpdateLog("AMAZINGCHARTS! ActivateDotNetFramework Custom Action");

                //open powershell process to activate the .net framework feature. See: 
                //http://community.flexerasoftware.com/archive/index.php?t-182914.html                
                startInfo = new ProcessStartInfo();
                startInfo.FileName = "powershell.exe";
                startInfo.Arguments = "Import-Module ServerManager ; Add-WindowsFeature as-net-framework";
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                startInfo.UseShellExecute = true;

                string sLogMsg = "";
                p = new Process();
                p.StartInfo = startInfo;

                sLogMsg = "ProcessStartInfo Data ... ";
                logWriter.UpdateLog(sLogMsg);
                sLogMsg = "FileName: " + p.StartInfo.FileName + "\n Arguments:" + p.StartInfo.Arguments;
                logWriter.UpdateLog(sLogMsg);

                p.Start();
                p.WaitForExit();
                sLogMsg = "ActivateDotNetFramework Custom Action Return Code: " + p.ExitCode.ToString();
                logWriter.UpdateLog(sLogMsg);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {

            }
        }
    }
}

VS2010でこれをどのように進めるべきかについてのアイデアはありますか? それとも、Wise Installation Studio パッケージの CA 構成に問題がありますか? 私が見る限り、VS2010 は管理された ActivateDotNetFramework.dll ファイルのみをビルドし、他には何もビルドしません。このファイルを wise パッケージのリソースに追加し、関数名を ActivateDotNetFramework としてリストしました。

私はこれを1日以上行っています。どんな助けでも大歓迎です。ありがとう。

ダン・リー AmazingCharts! リリースエンジニア

4

1 に答える 1

1

そのコードは、EXE としてコンパイルし、EXE カスタム アクションとして実行する必要があります。しかし、私のより大きな質問は、なぜわざわざ気にするのですか? 機能をインストールするために Windows で行う必要があるのは、次の呼び出しだけです。

dism /online /Enable-Feature FeatureName

機能名のリストについては、次のように入力します。

dism /online /Get-Features

于 2012-01-19T21:43:09.900 に答える