这是我在stackoverflow上的第一篇文章。当我从VS 2013(F6键)应用程序构建我的 WPF,.NET40 项目运行正常,但是当我使用msbuild自动构建和部署我的应用程序时,那么我总是在开始时崩溃。
我的msbuid代码:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="default">
<PropertyGroup>
<BaseDir>$(MSBuildProjectDirectory)</BaseDir>
<BinariesDir>$(MSBuildProjectDirectory)\mui\1.0\FirstFloor.ModernUI\Build\Binaries</BinariesDir>
<OutputDir>$(MSBuildProjectDirectory)\Setup\BuildResults\net4</OutputDir>
<Configuration Condition="'$(Configuration)'==''" >Release</Configuration>
<Platform Condition="'$(Platform)'==''">x86</Platform>
<PlatformTarget Condition="'$(PlatformTarget)'==''">x86</PlatformTarget>
<AllowUnsafeBlocks Condition="'$(AllowUnsafeBlocks)'==''">true</AllowUnsafeBlocks>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)'==''">v4.0</TargetFrameworkVersion>
<DefineConstants Condition="'$(DefineConstants)'==''">TRACE;NET4</DefineConstants>
<OutputPath Condition="'$(OutputPath)'==''">bin\AutoBuild\$(platform)\</OutputPath>
<MSBuildExtensions>$(BinariesDir)\MSBuild.Community.Tasks.dll</MSBuildExtensions>
<!--<SolutionFile>$(BaseDir)\Charon.sln</SolutionFile>-->
<SolutionFile>$(BaseDir)\cmu\cmu.csproj</SolutionFile>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<UsingTask AssemblyFile="$(MSBuildExtensions)" TaskName="MSBuild.Community.Tasks.XmlUpdate" />
<UsingTask AssemblyFile="$(MSBuildExtensions)" TaskName="MSBuild.Community.Tasks.Zip" />
<Target Name="default" DependsOnTargets="Clean; Compile" />
<Target Name="Clean">
<!-- clear output dir -->
<RemoveDir Directories="$(OutputDir)" />
</Target>
<Target Name="Compile">
<MSBuild
Projects="$(SolutionFile)"
Targets="Clean;Build"
Properties="
Configuration=$(Configuration);
Platform=$(Platform);
PlatformTarget=$(PlatformTarget);
AllowUnsafeBlocks=$(AllowUnsafeBlocks);
TargetFrameworkVersion=$(TargetFrameworkVersion);
DefineConstants=$(DefineConstants);
OutputPath=$(OutputDir)"/>
</Target>
</Project>
和bat文件,用于运行msbuild:
@echo off
set msBuild=%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
set innoSetup="%programfiles(x86)%\Inno Setup 5\iscc.exe"
rem Charon applications bulid version
set /a bulidVersion=(%date:~0,4%-2011)*12+%date:~5,2%
set appVersion=2.0.%bulidVersion%%date:~8,2%
rem MarcorpUpdater buid version AsmVersionMarcorpUpdater
set /a bulidVersion=(%date:~0,4%-2014)*12+%date:~5,2%
set marcorpUpdaterBuiltVersion = 1.0.%bulidVersion%%date:~8,2%
@echo on
rem call %msBuild% cmu\cmu.csproj /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net45;PlatformTarget=x86;TargetFrameworkVersion=v4.5;DefineConstants="NET45;TRACE";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=cmu_Manual_MSBuild_LOG.net45.log /t:Rebuild
rem call %msBuild% charon\charon.cspro`enter code here`j /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net45;PlatformTarget=x86;TargetFrameworkVersion=v4.5;DefineConstants="NET45;TRACE";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=charon_Manual_MSBuild_LOG.net45.log /t:Rebuild
rem call %msBuild% cmu\cmu.csproj /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net4;PlatformTarget=x86;TargetFrameworkVersion=v4.0;DefineConstants="TRACE;NET4";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=cmu_Manual_MSBuild_LOG.net4.log /t:Rebuild
call %msBuild% build.msbuild /p:AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=cmu_Manual_MSBuild_LOG.net4.log
pause
rem call %msBuild% charon\charon.csproj /p:Configuration=Release;Platform=x86;AllowUnsafeBlocks=true;OutputPath=..\Setup\BuildResults\net4;PlatformTarget=x86;TargetFrameworkVersion=v4.0;DefineConstants="NET4;TRACE";AsmVersion="%appVersion%.*" /l:FileLogger,Microsoft.Build.Engine;logfile=charon_Manual_MSBuild_LOG.net4.log /t:Rebuild
rem call %innoSetup% Setup\setup.iss "/dMyAppVersion=%appVersion%"
@echo off
set msBuild=
set innoSetup=
set appVersion=
set bulidVersion=
set marcorpUpdaterBuiltVersion=
崩溃:
Application: net.marcorp.charon.modernui.exe
Framework version: v4.0.30319
Description: The process was terminated due to an unhandled exception..
Exception Info: System.Windows.Markup.XamlParseException
Stack:
at: System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at: System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri) at: System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at: System.Windows.Application.LoadComponent(System.Object, System.Uri)
at: net.marcorp.charon.modernui.App.InitializeComponent()
at: net.marcorp.charon.modernui.App.Main()