3

cc.net で多くのソリューションを含むプロジェクトの公開を自動化しようとしています。私は msbuild を使用しており、これは aspnetcompiler xml ファイルを呼び出します。問題は、ディレクトリに多くのソリューションが含まれていることです。aspnetcompiler を実行すると、次のエラーが表示されます。

errorASPCONFIG: allowDefinition='MachineToApplication' として登録されたセクションをアプリケーション レベルを超えて使用するとエラーになります。このエラーは、IIS で仮想ディレクトリがアプリケーションとして構成されていないことが原因である可能性があります

多くのフォーラムで提供されているすべての可能な解決策を試しました。しかし、20 個のプロジェクトから特定のプロジェクトを実行するように aspnet_compiler に明示的に指示する方法がわかりません。

  I am using the ccnet build to call aspnet complier 
  <msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
    <!--msbuild exe directory -->
    <workingDirectory>C:\cc\test\code\</workingDirectory>
    <!--your working directory -->
    <projectFile>C:\Program Files\CruiseControl.NET\server\AspNetCompilerConfiguration.xml</projectFile>
    <!--the configuration xml file which will hold  AspNetCompiler  lines-->
    <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
  </msbuild>

これは私の AspNetCompilerConfiguration.xml ファイルです

<Project
    xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
    name = "AspNetPreCompile"
    DefaultTargets = "PrecompileWeb">
    <Target Name = "PrecompileWeb">
            <AspNetCompiler
                    VirtualPath = "test" 
                    PhysicalPath = "C:\cc\test\code\"
                    TargetPath = "C:\cc\testitr\deploy\"
                    Force = "true"
                    Debug = "true"
                    Updateable = "true"/>
    </Target>
</Project> 

ここで、C:\cc\test\code\Com.Project1.sln を実行します。しかし、aspnetコンパイラに伝える方法がわかりません。これを行う方法を考えてから、これを公開してください。

4

1 に答える 1

0

まず第一に、aspnet_compilerを使用してscirptでWebサイトを公開することはできませんが、一般的に同じことであるWebサイトを(リリースモード-)コンパイルすることはできます。または、この投稿で説明する方法でMsBuildを使用することもできます。

ASP.NET Webサイトをソリューションファイルにグループ化し、それらをビルドすることをお勧めします。そうすれば、パラメーターが少なくなり、VisualStudioでビルドをテストできます。

msbuild-scirptのcc.netビルドファイルでいくつかのパラメータを使用する方法は次のとおりです。

  <msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
    <!--msbuild exe directory -->
    <workingDirectory>C:\cc\test\code\</workingDirectory>
    <!--your working directory -->
    <projectFile>C:\Program Files\CruiseControl.NET\server\AspNetCompilerConfiguration.xml</projectFile>
    <!--the configuration xml file which will hold  AspNetCompiler  lines-->
    <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
    <!--Build arguments. You can have multiple projects or msbuild sections in cc.net.config-->
    <buildArgs>/p:Configuration=Debug;MyAttribute1=MyValue1;MyAttribute2=MyValue2;</buildArgs>
    <!--targets, if not default (here PrecompileWeb) -->
    <targets>Build;Analyze</targets>
  </msbuild>

次に、AspNetCompilerConfiguration.xml(私の意見ではMyWebSites.msbuildのような名前の方が適切です)を変更して、パラメーターを取得できます。

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" name = "AspNetPreCompile"    DefaultTargets = "PrecompileWeb">
  <!--Conditions are params from ccnet.config (or command line)-->
  <PropertyGroup Condition="'$(MyAttribute1)' == MyValue1" >
    <MySolution>c:\mything.sln</MySolution>
  </PropertyGroup>
  <PropertyGroup Condition="'$(MyAttribute1)' != MyValue1" >
    <MySolution>c:\some_other.sln</MySolution>
  </PropertyGroup>

  <!--This way you could import other msbuild-scirpts to manage separate files-->
  <!--<Import Project="Morexml.msbuild"/>-->

  <Target Name="Build">
    <Exec Command="echo hello world 1!"/>
    <MSBuild Projects="$(MySolution)" Targets="Rebuild" ContinueOnError="false" StopOnFirstFailure="false" />
  </Target>
  <Target Name="Analyze">
    <Exec Command="echo hello world 2!"/>
  </Target>
  <!--default, for example, here call some tasks -->
  <!--default is not used when targets are specified -->
  <Target Name="PrecompileWeb">
    <CallTarget Targets="Build" />
    <CallTarget Targets="Analyze" Condition="'$(MyAttribute2)' != 'MyValue2'" />
  </Target>
</Project>

ソリューションの.slnファイルは、VisualStudioまたはメモ帳で構成できます。ただし、次のようなWebサイトが必要です。

Project("{ABCD1234-7377-472B-9ABA-BC803B73C123}") = "MyWebSite", "http://localhost/MyWebSite", "{12345678-5FD6-4177-B210-54045B098ABC}"
    ProjectSection(WebsiteProperties) = preProject
        Debug.AspNetCompiler.VirtualPath = "/MyWebSite"
        Debug.AspNetCompiler.PhysicalPath = "..\..\MyWebSite\"
        Debug.AspNetCompiler.TargetPath = "C:\MyPublishedWebsite\"
        Debug.AspNetCompiler.Updateable = "false"
        Debug.AspNetCompiler.ForceOverwrite = "true"
        ...

そこにプロパティを見ることができます。IISを構成する必要はありません。(リリースされたWeb.Config(リリース/デバッグなどの設定)を確認するか、msbuild-Targetを使用して処理します。)

お役に立てれば!

于 2009-12-09T12:38:24.540 に答える