views:

227

answers:

1

I have attempted the following:

 <!-- Specify the inputs by type and file name -->
<ItemGroup>
    <CSFile Include = "$(MSBuildProjectDirectory)\..\Mine.cs"/>
</ItemGroup>

<Target Name = "Compile">
    <!-- Run the Visual C# compilation using input files of type CSFile -->
       <Csc Sources="@(CSFile)" />
    <!-- Log the file name of the output file -->
    <Message Text="The output file is done"/>
</Target>

This does not work as all the namespaces used in the project throw errors. Does anyone know how I can explicitly get the assemblies to pick up from the solution file, as the paths are ok and if loaded in Visual Studio all is fine. I need to script this and the above is not working. Is there an obvious mishap?

Appreciate the inpuT :-)

I have realised that this is not going to work as the file I have has several external dependancies. Hence I would need to use the devenv.exe. Problem is that I get the follwing:

What I get is that the command exits with Code 1? I want to get the project to build all the dependant dlls that it requires without having to open visual studio.

Any ideas?

Thnxes :-)

A: 

try this (add you own dlls references)

<ItemGroup>
  <CSFile Include = "$(MSBuildProjectDirectory)\..\Mine.cs"/>
  <Reference Include="System.dll"/>
  <Reference Include="System.Data.dll"/>
  <Reference Include="System.Drawing.dll"/>
  <Reference Include="System.Windows.Forms.dll"/>
  <Reference Include="System.XML.dll"/>
</ItemGroup>
<Target Name = "Compile">
    <!-- Run the Visual C# compilation using input files of type CSFile -->
       <Csc Sources="@(CSFile)" 
            References="@(Reference)"
            OutputAssembly="$(builtdir)\$(MSBuildProjectName).exe"
            TargetType="exe" />
            />
    <!-- Log the file name of the output file -->
    <Message Text="The output file is done"/>
</Target>
Gary