Symptoms
1.
Recently we have installed K2 4.7 and .NET Framework 4.6.1. We can build and deploy our project like before from Visual Studio. But, as part of our automated build process when we try to run MSBuild on the project/solution the project fails to build.
I am trying to Run MSbuild to build a workflow project, not K2 PandD. I run this command in Powershell:
.MSBuild MyWorkflow.k2proj . I get the following error:
" C:Program Files (x86)MSBuildSourceCodev3.5ProjectSystem.targets (17, 0)
Exception has been thrown by the target of an invocation.
Please ensure that the needed configuration node(s) are configured in your configuration file C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild.exe.Config. Please refer to the help documentation for further details.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Booleanand canBeCached, RuntimeMethodHandleInternaland ctor, Booleanand bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMarkand stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMarkand stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at SourceCode.Framework.SerializationInfo2.CreateInstance(PersistableContainerObject parent)
at SourceCode.Framework.SerializationInfo2.Load(PersistableObject instance, XmlReader reader)
at SourceCode.Framework.SerializationInfoProvider.Load(PersistableObject instance, XmlReader reader)
at SourceCode.Framework.SerializationInfoProvider.Load(TextReader reader)
at SourceCode.ProjectSystem.ProjectFile.Open(TextReader reader)
at SourceCode.ProjectSystem.ProjectFile.Open(Boolean showDesigner)
at SourceCode.DeploymentTasks.Compiler.WorkflowCompiler.Execute()"
This is the same error that we get in our TFS automated build process.
I have tried both : C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe and C:WindowsMicrosoft.NETFramework64v4.0.30319MSBuild.exe
However if I add
OR at the end of the .k2proj file it builds successfully.
So I am wondering what might be the possible cause of it and is it safe to modify the project file? Do we always have to modify the project file to build it using MSBuild?
2.
I can not open the project properties in Visual Studio any more. It says "The preview of this item is unavailable". But I can open the project properties from other machines where I have not installed .NET Framework 4.6.1 SDK and updated K2 to 4.7
Diagnoses
1.
Please see this KB article: http://help.k2.com/kb001637
According to that file, all configuration entries for Client Tools and Authoring APIs have been moved from all the .NET Machine.Config files to the individual application config files.
This means you have to update your project's application config file with the text highlighted in that KB at the bottom (please read carefully for specifics).
2.
I was able to open the Project Properties in Visual Studio using K2 4.7 and .NET 4.6.1 - unfortunately I couldn't reproduce.
Resolution
1.
Just to re-iterate how I resolved it on my side:
0) I used the following file: C:WindowsMicrosoft.NETFrameworkv4.0.30319msbuild.exe.Config
1) Make sure your MSBuild.exe.Config file is accessible by your user by changing the Windows Security permissions for it. You will probably need to take ownership of the file and give your user "Modify" permissions. More info here: http://www.wikihow.com/Change-File-Permissions-on-Windows-7
2) I added the following lines to the section at the top:
.
.
.
3) I saved the file then tried to build the package again with MSBuild and it worked.
This means you have to modify the above entries to suit your environment and do the same.