0

MSBuild を使用して ASP.NET MVC3 アプリケーションをコンパイルしようとしています。DLL はMainメソッドを必要とせず、ターゲットがライブラリであることを指定したため、コンパイラが次の例外をスローするのはなぜですか。

CSC : error CS5001: Program 'c:\MvcApplication1\web\bin\MvcApplication1.dll' does not contain a static 'Main' method suitable for an entry point[C:\MvcApplication1\web\MvcApplication1.csproj]

.csproj ファイルは次のとおりです。

<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
        <OutputType>Library</OutputType>
        <AssemblyName>MvcApplication1</AssemblyName>
        <OutputPath>bin\</OutputPath>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="*.cs" />
    </ItemGroup>

    <ItemGroup>
        <Reference Include="..\lib\*.dll" />
    </ItemGroup>

    <Target Name="Build">
        <MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />
        <Csc References="@(Reference)" Sources="@(Compile)" OutputAssembly="$(OutputPath)$(AssemblyName).dll" />
        <Copy SourceFiles="@(Reference)" DestinationFolder="$(OutputPath)" />
    </Target>

</Project>
4

1 に答える 1

1

Cscの が必要TargetTypeですlibrary。デフォルトは Library (以下の MSDN を参照) であるはずですが、この場合はそうではないようです。

<Csc次のようにステップを変更します。

<Csc TargetType="library" References="@(Reference)"  ....  />

MSDN re TargetTypeから:

出力ファイルのファイル形式を指定します。このパラメーターには、コード ライブラリを作成する library、コンソール アプリケーションを作成する exe、モジュールを作成する module、または Windows プログラムを作成する winexe の値を指定できます。デフォルト値はライブラリです。詳細については、「/target (C# コンパイラ オプション)」を参照してください。

于 2011-12-14T00:22:39.563 に答える