Msbuild 中的 CSC 任务因命名空间错误而中止

发布于 2024-08-05 06:47:53 字数 805 浏览 13 评论 0原文

我尝试了以下操作:

 <!-- 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>

这不起作用,因为项目中使用的所有命名空间都会抛出错误。有谁知道我如何显式地从解决方案文件中获取程序集,因为路径没问题,并且如果在 Visual Studio 中加载,一切都很好。我需要编写这个脚本,而上面的内容不起作用。有明显的事故吗?

感谢您的输入:-)

我已经意识到这不会起作用,因为我拥有的文件有几个外部依赖项。因此我需要使用 devenv.exe。问题是我得到以下信息:

我得到的是命令退出时显示代码 1?我想让项目构建它所需的所有依赖 dll,而无需打开 Visual Studio。

有什么想法吗?

谢谢:-)

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 :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青丝拂面 2024-08-12 06:47:53

试试这个(添加你自己的dll引用)

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文