I'm creating an application to build and publish a Windows Workflow Foundation project.
I have the following configuration for testing the build:
Dictionary<String, String> globalProperty = new Dictionary<String, String>();
globalProperty.Add("Configuration", "Release");
globalProperty.Add("Platform", "Any CPU");
globalProperty.Add("OutputPath", $@"bin\release");
globalProperty.Add("VisualStudioVersion", "14.0");
globalProperty.Add("DeployOnBuild", "true");
globalProperty.Add("WebConfigTransformOutput", @"obj\Release\TransformWebConfig\transformed\Web.config");
globalProperty.Add("PublishProfile", "WWF Release.pubxml");
globalProperty.Add("DeleteExistingFiles", "true");
globalProperty.Add("WebPublishMethod", "FileSystem");
globalProperty.Add("publishUrl", @"C:\Test\WWF\");
BuildRequestData buildRequest = new BuildRequestData(
@"C:\Dev\WWF\MyWWF\MyWWF.csproj",
globalProperty,"14.0",
new[] { "Clean", "Build", "WebPublish" },
null);
ProjectCollection projectCollection = new ProjectCollection();
BuildParameters buildParameters = new BuildParameters(projectCollection)
{
DefaultToolsVersion = "14.0",
OnlyLogCriticalEvents = false,
DetailedSummary = true,
MaxNodeCount = Environment.ProcessorCount,
BuildThreadPriority = System.Threading.ThreadPriority.Normal,
MemoryUseLimit = 4000,
Loggers =
new List<ILogger>
{
new FileLogger
{
Parameters = @"logfile=C:\Test\test.log",
Verbosity = LoggerVerbosity.Diagnostic
}
}
};
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(buildParameters, buildRequest);
If I run the application in Visual Studio, it works fine: the project is built and published to the defined location.
However, if I run the application from the file system (bin\Debug or bin\Release folders) it fails during the build.
I've look into the logs and this is what I've found:
When running the application (Debug or Release) in Visual Studio:
1>Done building target "XamlTemporaryAssemblyGeneration" in project "MyWWF.csproj".: (TargetId:104)
Target "XamlMarkupCompileReadPass2Flag" skipped. Previously built successfully.
1>Target "XamlMarkupCompilePass2: (TargetId:112)" in file "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Xaml.targets" from project "C:\Dev\WWF\MyWWF\MyWWF.csproj" (target "PrepareResources" depends on it):
Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
Using "CompilationPass2Task" task from assembly "C:\Windows\Microsoft.NET\Framework\v4.0.30319\\XamlBuildTask.dll".
Task "CompilationPass2Task" (TaskId:83)
TextExpressionCompiler: Ignoring unnamed variable. (TaskId:83)
TextExpressionCompiler: Ignoring unnamed variable. (TaskId:83)
Done executing task "CompilationPass2Task". (TaskId:83)
When running the application (MyTestBuild.exe) from the bin\Debug or bin\Release folders:
1>Done building target "XamlTemporaryAssemblyGeneration" in project "MyWWF.csproj".: (TargetId:104)
Target "XamlMarkupCompileReadPass2Flag" skipped. Previously built successfully.
1>Target "XamlMarkupCompilePass2: (TargetId:112)" in file "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Xaml.targets" from project "C:\Dev\WWF\MyWWF\MyWWF.csproj" (target "PrepareResources" depends on it):
Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
Task "Message" skipped, due to false condition; ('$(MSBuildTargetsVerbose)'=='true') was evaluated as (''=='true').
Using "CompilationPass2Task" task from assembly "C:\Windows\Microsoft.NET\Framework\v4.0.30319\\XamlBuildTask.dll".
Task "CompilationPass2Task" (TaskId:83)
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Xaml.targets(347,5): error : Type 'MyWWF.VoidPaymentWorkflow.Activities.VoidPayment' cannot be inspected for expressions that need compilation. The constructor threw exception: 'Could not load file or assembly 'file:///C:\Dev\WWF\MyWWF\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll' or one of its dependencies. The system cannot find the file specified.'
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Xaml.targets(347,5): error : Type 'MyWWF.SaveInboundPaymentWorkflow.Activities.SaveInboundPayment' cannot be inspected for expressions that need compilation. The constructor threw exception: 'Could not load file or assembly 'file:///C:\Dev\WWF\MyWWF\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll' or one of its dependencies. The system cannot find the file specified.'
Done executing task "CompilationPass2Task" -- FAILED. (TaskId:83)
The file (C:\Dev\WWF\MyWWF\packages\Newtonsoft.Json.8.0.2\lib\net45\
Newtonsoft.Json.dll) is present in that location.
I've tried different configurations and even executed the application as administrator, but nothing seems to work.