I am using Visual Studio Code because it is more lightweight than Visual Studio but still gives me the intellisense. However I could not find a way for Code to build a .csproj or .sln automatically, so I have been making the files by scratch. There is little documentation on it so I had to go off of examples from other files. It was all good and fine, but recently I hit a snag where compiling it with msbuild does not give me the same result as compiling by csc.exe. I would get a BadImageFormatException whenever I would load in a dll and try and use one of it's classes. My question is, is there a way to have vscode generate a csproj or sln file as I create new projects? And if there isn't, is there a way around having to make the csproj files I have compile in the same fashion as I do with the batch files?
csproj file:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="Splicer.dll">
<HintPath>Splicer.dll</HintPath>
</Reference>
<Reference Include="DirectShowLib-2005.dll">
<HintPath>DirectShowLib-2005.dll</HintPath>
</Reference>
<Compile Include="src\*.cs" />
</ItemGroup>
<Target Name="Build">
<MakeDir Directories="$(OutputPath)"
Condition="!Exists('$(OutputPath)')"
/>
<Csc
Platform="x86"
NoWarn=""
Sources="@(Compile)"
OutputAssembly="$(OutputPath)$(AssemblyName).exe"
/>
</Target>
<PropertyGroup>
<AssemblyName>SplicerDemo</AssemblyName>
<OutputPath>bin\</OutputPath>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Batch Compiler:
@echo off
set "CSC=C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe"
set "Refs=Splicer.dll,DirectShowLib-2005.dll"
set "Files=src\SplicerDemo\*.cs"
set "Compile=%csc% /platform:x86 /r:%Refs% /out:SplicerDemo.exe /t:exe %Files$"
cmd
File to Compile:
using Splicer.Renderer;
using Splicer.Timeline;
using System.Drawing;
namespace SplicerDemo {
public class Start {
// Variables
public string outputFile;
public Start() {
outputFile= "Foo.avi";
}
public static void Main() {
Start s= new Start();
System.Console.WriteLine("Starting Build...");
s.save();
System.Console.WriteLine("Build Finished!");
}
// --- Methods ---
public void save() {
// Variables
DefaultTimeline timeline= new DefaultTimeline(24);
IGroup _group= timeline.AddVideoGroup(32, 1024, 786);
ITrack vtrack= _group.AddTrack();
ITrack atrack= timeline.AddAudioGroup().AddTrack();
Bitmap img= new Bitmap("image3.jpg");
vtrack.AddImage("image1.jpg", 0, 24);
vtrack.AddImage("image2.jpg", 0, 24);
vtrack.AddImage(img, 0, 100);
vtrack.AddImage("image1.jpg", 0, 128);
atrack.AddAudio("audio1.mp3", 0, vtrack.Duration);
using(AviFileRenderer renderer= new AviFileRenderer(timeline, outputFile)) {
renderer.Render();
}
}
}
}