.net - Dotnet 构建返回不同的结果
问题描述
当我在生成新的统一脚本后尝试构建我的 *.csproj 时,我遇到了一个奇怪的问题。让我解释一下工作流程。
首先,我要从 Unity 主目录中删除所有旧的 *.csproj 文件。然后我使用以下脚本来生成全新的项目文件
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in assemblies)
{
foreach (var type in assembly.GetTypes())
{
if (type.FullName == "Packages.Rider.Editor.ProjectGeneration.ProjectGeneration")
{
var projectGeneration = Activator.CreateInstance(type);
type.GetMethod("Sync").Invoke(projectGeneration,null);
EditorApplication.Exit(0);
}
}
}
接下来,我尝试通过 cmd 命令构建每个 *.csproj:dotnet build C:\Projects\xxx\xxx\*.csproj --force --no-restore
这就是奇怪的事情发生的地方。该命令的第一次运行总是返回许多错误和警告,但它们的实际数量每次都不同。第二次是减少它们的数量,第三次运行通常不会导致错误,只是出现一些警告。
我知道,我没有得到相关的结果,因为应该出现的警告在几次运行后没有被指出。
以下是一些出现的错误
CSC : error CS0006: Metadata file 'C:\Projects\xxx\xxx\Temp\Bin\Debug\ARFoundation.dll' could not be found [C:\Projects\xxx\xxx\xxx.csproj]
CSC : error CS0006: Metadata file 'C:\Projects\xxx\xxx\Temp\Bin\Debug\xxx_OclussionCulling.dll' could not be found [C:\Projects\xxx\xxx\xxx.csproj]
CSC : error CS0006: Metadata file 'C:\Projects\xxx\xxx\Temp\Bin\Debug\QuickGraph.dll' could not be found [C:\Projects\xxx\xxx\xxx.csproj]
CSC : error CS0006: Metadata file 'C:\Projects\xxx\xxx\Temp\Bin\Debug\Unity.XR.Interaction.Toolkit.dll' could not be found [C:\Projects\xxx\xxx\xxx.csproj]
我的问题是为什么会发生这种情况,我该如何解决?主要目标是自动化构建,但我必须单独构建每个 *.csproj,因为我需要从构建中排除一些 *.csproj。
解决方案
好的,所以我前段时间找到了解决方案。我的问题是,我没有以正确的顺序构建项目,这在这种情况下至关重要。
项目构建的有效顺序保存在主 *.sln 文件中。当您想要手动构建 *.csproj 文件时,您必须注意正确的顺序。
推荐阅读
- xml - 非空 IXMLNodeCollection.Count 返回 0
- oauth-2.0 - 如何使用节点 js 从访问令牌中获取谷歌刷新令牌和访问令牌
- scala - 有没有办法用scala中的高阶方法替换嵌套的For循环
- java - 如何修复错误创建名为“requestMappingHandlerMapping”的bean
- javascript - 如何在 nuxt.js 中导入 wavesurfer?
- mps - 在 MPS 中执行非 ui 阻塞任务并在任务完成后更改模型
- css - 如何为页面的特定部分添加背景图片?
- java - 由于 ViewPostIME,按钮不执行任何操作
- verilog - 如何计算位/字节大小?
- rest - Onion Architecture - 如果在将结构化数据(p.ex:一个对象)提供给用例后有一些数据要检查,接口应该做什么