简体   繁体   中英

MsBuild.exe vs. Visual Studio 2017 different output

I have an issue when i build my project with Visual Studio 2017, everything is working just fine, but when trying to build the project with msbuild.exe the output is different and is not working.

msbuild executed

msbuild.exe "myproj.csproj" /p:Configuration=Release;Platform="Any CPU";OutputPath="c:\pub\myproj"

Visual studio build settings: 在Visual Studio 2017中建立设定 Any sugestions what iam doing wrong, and how can I get the msbuild to make the same output as the Visual Studio build?

The error I get when trying to execute the code made with 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>)
...

It could indicate that some assemblies are missing or the references is broken when building with msbuild. I checked all the .dll thats references in the code is in the output in both scenarios.

Maybe you can try: 1.Use the msbuild.exe from:

C:\Program Files (x86)\Microsoft Visual Studio\2017\VSversion\MSBuild\15.0\Bin

2.Remove the space in "Any CPU", it should be like Platform="AnyCPU" instead of "Any CPU"

3.Uncheck the Optimize code to see if there has a difference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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