2011-12-14 86 views
0

我想使用MSBuild編譯我的ASP.NET MVC3應用程序。由於DLL的不需要Main方法,我已經指定的目標是一個圖書館,爲什麼編譯器拋出以下異常:MSBuild說我需要一個庫編譯的主要方法

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> 

回答

1

Csc應該有TargetTypelibrary。默認值應該是Library(見下面的MSDN),雖然在這種情況下似乎並不是這樣。

更改您<Csc步驟如下:

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

MSDN重新的TargetType

指定輸出文件的文件格式。該參數可具有 庫的值,該庫創建一個代碼庫exe,該代碼庫將創建一個 控制檯應用程序,用於創建模塊的模塊或用於創建Windows程序的winexe。默認值是庫。有關更多 信息,請參閱/ target(C#編譯器選項)。

+0

是的,我想我在我的.csproj文件中設置了`/ target:library` csc switch' Library`。 – nbsp 2011-12-14 00:24:59

相關問題