msbuild - MsBuild.exe 与 Visual Studio 2017 不同的输出
问题描述
我在使用 Visual Studio 2017 构建项目时遇到问题,一切正常,但在尝试使用 msbuild.exe 构建项目时,输出不同且无法正常工作。
msbuild 已执行
msbuild.exe "myproj.csproj" /p:Configuration=Release;Platform="Any CPU";OutputPath="c:\pub\myproj"
Visual Studio 构建设置: 我做错了什么,我怎样才能让 msbuild 产生与 Visual Studio 构建相同的输出?
尝试执行使用 msbuild 生成的代码时出现的错误
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Reflection.ReflectionTypeLoadException
at System.Reflection.RuntimeModule.GetTypes(System.Reflection.RuntimeModule)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at MyProj.V2.Infrastructure.Bootstrappring.BootstrapperBase+<>c__DisplayClass14_0.<RegisterInfrastructureComponents>b__0(AutoMapper.IMapperConfigurationExpression)
at AutoMapper.MapperConfiguration.Build(System.Action`1<AutoMapper.IMapperConfigurationExpression>)
at AutoMapper.Mapper.Initialize(System.Action`1<AutoMapper.IMapperConfigurationExpression>)
...
它可能表示使用 msbuild 构建时缺少某些程序集或引用已损坏。我检查了代码中引用的所有 .dll 都在两种情况下的输出中。
解决方案
也许您可以尝试: 1.使用来自以下位置的 msbuild.exe:
C:\Program Files (x86)\Microsoft Visual Studio\2017\VSversion\MSBuild\15.0\Bin
2.去掉“Any CPU”中的空格,应该是Platform="AnyCPU"而不是“Any CPU”
3.取消勾选优化代码,看看是否有区别
推荐阅读
- python - Python3 Exif 方向 KeyError: '274'
- python - 通过指向该函数的指针获取函数参数值?
- c - 如何将新的源文件添加到 glibc makefile?
- python - 使用 csv 写入数据库时没有这样的文件或目录
- selenium - Xpath 使用匹配和正则表达式在 Xpath 测试器中工作,但在代码中抛出 InvalidSelectorException 无法在“文档”上执行“评估”
- javascript - 如何按日期对 JSON 进行排序?
- c++ - 什么是有序向量树?
- java - 显示字符串“x”次数
- bash - 无法在 .sh 脚本中使用“&”作为后台 HTTPie http 请求
- charts - 您如何更改图表中的时间轴?