简体   繁体   English

如何在没有默认 DLL 文件的情况下编译 C# Visual Studio 项目?

[英]How can I compile a C# visual studio project without the default DLL file?

I'll just cut straight to the point.我直接切入正题。

I am making a compiler in C#, and creating it using visual studio.我正在 C# 中制作编译器,并使用 Visual Studio 创建它。 When I build my compiler to an executable, it also builds a "runtime" dll, how can I force visual studio to only build the executable without the dll?当我将编译器构建为可执行文件时,它还会构建“运行时”dll,如何强制 Visual Studio 仅构建没有 dll 的可执行文件? (this is a .net core project) (这是一个.net核心项目)

hypec.csproj hypec.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

</Project>

solution解决方案


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29509.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hype", "hype.csproj", "{4653DC57-ACFF-419D-A57C-CEF0B5ECA174}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {4653DC57-ACFF-419D-A57C-CEF0B5ECA174}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {4653DC57-ACFF-419D-A57C-CEF0B5ECA174}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {4653DC57-ACFF-419D-A57C-CEF0B5ECA174}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {4653DC57-ACFF-419D-A57C-CEF0B5ECA174}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(ExtensibilityGlobals) = postSolution
        SolutionGuid = {8D8BF52E-5BB5-4F40-8365-9A6C3EBD042E}
    EndGlobalSection
EndGlobal

From the reference here: https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0从这里的参考: https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-3-0

To publish a single-file executable, set the PublishSingleFile in your project or on the command line with the dotnet publish command:要发布单文件可执行文件,请在项目中或使用 dotnet publish 命令在命令行中设置 PublishSingleFile:

<PropertyGroup>
  <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  <PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>

OR或者

dotnet publish -r win10-x64 -p:PublishSingleFile=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将dll项目设置整合到Visual Studio 2010中用于C#应用程序的主exe.config文件中? - How can I consolidate my dll project settings into my main exe.config file in Visual Studio 2010 for a C# application? 如何在Visual Studio C#项目中编译hlsl着色器文件 - How to compile hlsl shader file in Visual Studio C# project 如何在我的 Visual Studio Code c# 项目中设置默认的 c# 文件? - How do I set the default c# file in my Visual Studio Code c# Project? 如何在我的 C# Visual Studio 项目中添加 VC++ DLL 作为参考? - How can I add a VC++ DLL as a reference in my C# Visual Studio project? 如何在没有Visual Studio的系统上编译.NET 3.5 C#代码? - How can I compile .NET 3.5 C# code on a system without Visual Studio? 如何在不涉及Visual Studio的情况下编译C#解决方案? - How can I compile a C# solution without involving Visual Studio? 在Visual Studio 2010 C#项目中将.chm文件链接到.dll - Linking a .chm file to a .dll in Visual Studio 2010 C# Project 如何在没有项目的情况下编译C#文件? - How to compile C# file without a project? 如何在没有 Visual Studio 的 CLI 项目中添加.dll 文件? - How to add .dll file in CLI project without visual studio? 如何编译完成的 C# 项目,然后在 Visual Studio 之外运行? - How to compile the finished C# project and then run outside Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM