小编PGo*_*cer的帖子

vscode 有 csproj 生成器吗?

我使用 Visual Studio Code 是因为它比 Visual Studio 更轻量级,但仍然提供智能感知功能。但是我找不到代码自动构建 .csproj 或 .sln 的方法,所以我一直从头开始制作文件。关于它的文档很少,所以我不得不放弃其他文件中的示例。一切都很好,但最近我遇到了一个障碍,用 msbuild 编译它并不能得到与 csc.exe 编译相同的结果。每当我加载 dll 并尝试使用它的类之一时,我都会收到 BadImageFormatException。我的问题是,有没有办法让 vscode 在我创建新项目时生成 csproj 或 sln 文件?如果没有,是否有办法让我以与批处理文件相同的方式编译 csproj 文件?

csproj 文件:

<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" />
Run Code Online (Sandbox Code Playgroud)

批处理编译器:

@echo off
set "CSC=C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe"
set "Refs=Splicer.dll,DirectShowLib-2005.dll"
set …
Run Code Online (Sandbox Code Playgroud)

c# msbuild batch-file csc visual-studio-code

6
推荐指数
1
解决办法
6822
查看次数

标签 统计

batch-file ×1

c# ×1

csc ×1

msbuild ×1

visual-studio-code ×1