2016-04-06 65 views
0

我为编译多个文件写了一个文件,但它不起作用。为多个文件创建一个msbuild

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Compile"> <ItemGroup> <FilesToCompile Include="hola.cs"/> <FilesToCompile Include="hola2.cs"/> </ItemGroup> <PropertyGroup>
<AssemblyName>Proyecto</AssemblyName> <OutputPath>Bin\</OutputPath>
<Optimize>false</Optimize> </PropertyGroup> <Target Name="Compile"> <MakeDir Directories="$(OutputDir)"/> <Csc Sources="@(FilesToCompile)" OutputAssembly="$(OutputPath)$(AssemblyName)" Optimize="$(Optimize)" TargetType="exe" /> </Target> </Project>

这表明我这个错误。 enter image description here

英文:

错误CS0017:程序 '输出文件名' 有多个定义的一个入口点。用/ main编译指定包含入口点的类型。

+0

你可以得到一个英文版本的错误并将其作为文本发布,而不是图像? –

+0

当然@dangerzone,错误CS0017:程序'输出文件名'有多个定义的入口点。用/ main编译指定包含入口点的类型。 – MagnunStalin

回答

0

我自己解决了。

<Project DefaultTargets = "Compile" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" > 
<PropertyGroup> 
<NombreClase1>hola1</NombreClase1> 
<NombreClase2>hola2</NombreClase2> 
</PropertyGroup> 
<ItemGroup> 
<Clase1 Include = "hola.cs"/>    
<Clase2 Include = "hola2.cs"/>    
</ItemGroup> 
<Target Name = "Compile">    
<CSC Sources = "@(Clase1)" OutputAssembly = "$(NombreClase1).exe">    
<Output TaskParameter = "OutputAssembly" ItemName = "Ejecutable1" />       
</CSC>   
<Message Text="Archivo compilado @(Ejecutable1)"/>   
<CSC Sources = "@(Clase1)" OutputAssembly = "$(NombreClase2).exe"> 
<Output TaskParameter = "OutputAssembly" ItemName = "Ejecutable2" />      
</CSC> 
<Message Text="Archivo compilado @(Ejecutable2)"/>  
</Target>      
</Project>