MsBuild.exe与Visual Studio 2017不同的输出

MsBuild.exe与Visual Studio 2017不同的输出,msbuild,visual-studio-2017,Msbuild,Visual Studio 2017,我在使用Visual Studio 2017构建项目时遇到了一个问题,一切正常,但在尝试使用msbuild.exe构建项目时,输出不同,无法正常工作 已执行msbuild msbuild.exe "myproj.csproj" /p:Configuration=Release;Platform="Any CPU";OutputPath="c:\pub\myproj" Framework Version: v4.0.30319 Description: The process was termi

我在使用Visual Studio 2017构建项目时遇到了一个问题,一切正常,但在尝试使用msbuild.exe构建项目时,输出不同,无法正常工作

已执行msbuild

msbuild.exe "myproj.csproj" /p:Configuration=Release;Platform="Any CPU";OutputPath="c:\pub\myproj"
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>)
...
Visual studio生成设置: 任何关于我做错了什么的建议,以及如何让msbuild生成与Visual Studio生成相同的输出

尝试执行使用msbuild生成的代码时出现的错误

msbuild.exe "myproj.csproj" /p:Configuration=Release;Platform="Any CPU";OutputPath="c:\pub\myproj"
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>)
...
框架版本:v4.0.30319
描述:由于未处理的异常,进程已终止。
异常信息:System.Reflection.ReflectionTypeLoadException
位于System.Reflection.RuntimeModule.GetTypes(System.Reflection.RuntimeModule)
在System.Reflection.RuntimeModule.GetTypes()中
在System.Reflection.Assembly.GetTypes()处
在MyProj.V2.Infrastructure.Bootstrappring.BootstrapperBase+c__DisplayClass14_0.b__0(AutoMapper.IMapperConfigurationExpression)
在AutoMapper.MapperConfiguration.Build(System.Action`1)
在AutoMapper.Mapper.Initialize处(System.Action`1)
...
它可能表示在使用msbuild生成时缺少某些程序集或引用已断开。我检查了两种情况下输出中代码中引用的所有.dll。

也许您可以尝试: 1.从以下位置使用msbuild.exe:

C:\Program Files (x86)\Microsoft Visual Studio\2017\VSversion\MSBuild\15.0\Bin
2.删除“任意CPU”中的空格,它应该类似于Platform=“AnyCPU”而不是“任意CPU”


3.取消选中优化代码以查看是否存在差异

请尝试我的答案。希望能有帮助。如果可能的话,你可以分享你的项目的一个简单的例子,这样我就可以直接检查它,或者通过一个驱动器共享它,我会在我这边构建并检查它。