简体   繁体   English

使用 msbuild 构建/运行 .Net 应用程序

[英]Building/Running .Net Application with msbuild

I have a project written in .net 4.8 and I'm able to successfully build it with msbuild but I don't know what I'm supposed to do after this, I see there's a dll file named after the project in the bin folder as well as obj/debug but when I try to use mono to run it I get <dll_name.dll> doesn't have an entry point but I'm doing it this way only because as far as I know, it's the best way.我有一个用 .net 4.8 编写的项目,我可以使用 msbuild 成功构建它,但我不知道在此之后我应该做什么,我看到 bin 文件夹中有一个以项目命名的 dll 文件以及 obj/debug 但是当我尝试使用 mono 运行它时,我得到<dll_name.dll> doesn't have an entry point ,但我这样做只是因为据我所知,这是最好的方法.

I was using Monodevelop for this project but I came to find out that it doesn't support async methods that return views and that it's a PR request that was merged just a few years ago so I'm think it didn't make it into the IDE.我在这个项目中使用 Monodevelop,但我发现它不支持返回视图的异步方法,而且它是几年前合并的 PR 请求,所以我认为它没有进入IDE。

The project runs almost fine in monodevelop aside from the prior error because it runs a command to include the namespaces as it should.除了先前的错误外,该项目在 monodevelop 中几乎可以正常运行,因为它运行了一个命令以包含应有的名称空间。 Some things I've tried:我尝试过的一些事情:

  • csc StartUp.cs which tells me there are several missing namespaces, is the only way to go through and reference all of these individually in the command? csc StartUp.cs告诉我缺少几个命名空间,这是在命令中单独查看和引用所有这些命名空间的唯一方法吗?
  • mono bin/ProjectName.dll but it tells me it has no entry point and this command might not even be what I'm looking for to begin with mono bin/ProjectName.dll但它告诉我它没有入口点,这个命令甚至可能不是我想要的
  • mono obj/Debug/ProjectName.dll same as above but a different file. mono obj/Debug/ProjectName.dll与上面相同,但文件不同。

For reference: mono The view 'Index' or its master was not found So the PR was merged into mono but I don't believe monodevelop is using the updated version of mono, maybe if I could tell the monodevelop IDE to use the latest version?供参考: mono 未找到视图“索引”或其主视图因此 PR 已合并到 mono 但我不相信 monodevelop 正在使用 mono 的更新版本,也许我可以告诉 monodevelop IDE 使用最新版本?

To clarify: I'm on Ubuntu and this project won't run with the new dotnet commands so I've taken to using mono for it, my goal is to be able to build the project and then run it so I can make changes to it.澄清一下:我在 Ubuntu 上,这个项目不会使用新的 dotnet 命令运行,所以我已经开始使用 mono,我的目标是能够构建项目然后运行它,以便我可以进行更改给它。 I believe I already have the build part down as msbuild returns 0 errors but I'm lost after that.我相信我已经将构建部分关闭,因为msbuild返回 0 个错误,但在那之后我迷路了。 It's a web-based application这是一个基于网络的应用程序

You should not have to invoke csc directly to build your project, but the exact cause of your problem is unclear.您不必直接调用csc来构建您的项目,但问题的确切原因尚不清楚。 Instead, try building through Monodevelop or by invoking msbuild .相反,尝试通过 Monodevelop 或调用msbuild进行构建。 Try posting your .csproj file if you have one.如果有,请尝试发布您的 .csproj 文件。 In particular, check the <OutputType> tags.特别是,检查<OutputType>标记。 Also, try doing a "Release" build instead of a "Debug" build.此外,尝试进行“发布”构建而不是“调试”构建。

Your .csproj instructs the compiler to produce a library, so that is probably why Monodevelop gives you a library.您的 .csproj 指示编译器生成一个库,因此这可能是 Monodevelop 为您提供库的原因。 You get errors regarding dependencies with csc and mcs because they do not know about your project.您会收到有关cscmcs依赖项的错误,因为它们不了解您的项目。 Instead, use msbuild or build inside Monodevelop.相反,使用msbuild或在 Monodevelop 内部构建。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM