为需要DLL的MONO构建csproj

为需要DLL的MONO构建csproj,dll,msbuild,mono,csproj,xbuild,Dll,Msbuild,Mono,Csproj,Xbuild,我有一行代码是从一个名为 gmcs -r:System.Windows.Forms.dll -r:System.Drawing.dll 01-simple-cs-example.cs -out:simple-sample.exe 这将生成绘制窗口的exe,但我认为我的csproj文件不正确 <Project DefaultTargest="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

我有一行代码是从一个名为

gmcs -r:System.Windows.Forms.dll -r:System.Drawing.dll 01-simple-cs-example.cs -out:simple-sample.exe
这将生成绘制窗口的exe,但我认为我的
csproj
文件不正确

<Project DefaultTargest="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <!-- This Property will make a variable named MSBuildSample, then you can use it to 
            assign to whatever in the script.
            Properties are variables inside the script.
        -->
        <SrcPath>src\</SrcPath>
        <AssemblyName>01-simple-cs-example</AssemblyName>
        <OutputPath>bin\</OutputPath>
    </PropertyGroup>

    <ItemGroup>
        <!-- This Compile statement, gathers all the source files listed in an item called Compiled 
            ItemGroups interact with the source code.
        -->
        <Compile Include="$(SrcPath)01-simple-cs-example.cs" />
    </ItemGroup>
    <!-- In the Build target, the Inputs and Outputs targets which looks to see if the files have been updated,
        or if the files are existent. If the files have not been changed, then the Build target is skipped. 
    -->
    <Target Name="Build" Inputs="@(Compile)" Outputs="$(OutputPath)$(AssemblyName).exe" >
        <!-- The MakeDir directive will create the directory in the property group above, if it meets the 
            condition stated in the Condition= statement. 
        -->
        <Message Text="Creating the output path $(OutputPath)." />
        <MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />
        <!-- This Csc is the .NET C# compiler, which then uses the ItemGroup of collected sources called, Compile 
        -->
        <Message Text="Compiling the source code." />
        <Csc Sources="@(Compile)" OutputAssembly="$(OutputPath)$(AssemblyName).exe" />
    </Target>



</Project>
这是MSBuild运行的结果。MSBuild已成功完成,但我想这是因为MSBuild知道在何处查找,而无需在
csproj
文件中指定它

C:\Users\User01\Dropbox\programming\csharp\zetcode-csharp-winforms\01-simple-cs-example>MSBuild
Microsoft (R) Build Engine version 4.0.30319.18408
[Microsoft .NET Framework, version 4.0.30319.18444]
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 7/25/2014 2:48:04 PM.
Project "C:\Users\User01\Dropbox\programming\csharp\zetcode-csharp-winforms\01-simple-cs-example\01-simple-cs-example.csproj" on node 1 (default targets).
Build:
  C:\Windows\Microsoft.NET\Framework\v2.0.50727\Csc.exe /out:bin\01-simple-cs-example.exe src\01-simple-cs-example.cs
Done Building Project "C:\Users\User01\Dropbox\programming\csharp\zetcode-csharp-winforms\01-simple-cs-example\01-simple-cs-example.csproj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.36
我不知道要在
csproj
文件中放入什么,才能让它加载我在命令行中使用的DLL,以便使用
gmcs
进行编译。有什么线索吗

使用来自的答案后,我能够看到
引用如何添加到
csproj
文件中。只需添加一个项目组,然后使用
在C#源文件中添加您列出的引用即可

  <ItemGroup>
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Drawing" />
    <Reference Include="System" />
  </ItemGroup>


如果您正在手动构建
csproj
文件,这是一种手动方式

只需使用IDE(MonoDevelop或Visual Studio)添加对
System.Windows.Forms
System.Drawing
库的GAC引用。

此外,这里的页面将我带到一个过时且不完整的页面。虽然这是一个答案,这不是我想要的,因为我不想使用IDE,除非我理解手动方式。我一般也不喜欢使用IDE。谢谢你的贡献。希望它也能帮助人们寻找这个。好吧,好吧,.csproj文件不是由人类创建的,这就是为什么我假设你不喜欢IDE。。。你应该在你的问题中说明你对IDE的厌恶使用IDE肯定会让事情变得更简单,但我仍然不完全理解sln文件的意义,以及它是如何与csproj文件联系在一起的。不过我现在还是坚持使用IDE
  <ItemGroup>
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Drawing" />
    <Reference Include="System" />
  </ItemGroup>