TFS 2010 Build SharePoint with WCF Service - wcf

I am attempting to set up some continuous integration for a clients SharePoint environment.
The issue I am running into is with SharePoint projects that include a WCF service.
The project in question builds fine but fails when it attempts to package and deploy on the build server.
The project builds and deploys fine from Visual Studio, the problem only occurs on the TFS Build server.
The Error thrown by the Build Agent is as follows:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets (378): The "ValidatePackage" task failed unexpectedly. System.InvalidOperationException: The project service is not a serialized SharePoint project service. at Microsoft.VisualStudio.SharePoint.Tasks.ValidatePackage.OnCheckParameters() at Microsoft.VisualStudio.SharePoint.Tasks.BuildTask.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)
The following is the error from MSBuild Logs :
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets(378,5): error MSB4018: The "ValidatePackage" task failed unexpectedly. [C:\BuildsNew\4\SharePrice\SharePrice_Dev\Sources\SharePrice\SharePrice.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets(378,5): error MSB4018: System.InvalidOperationException: The project service is not a serialized SharePoint project service. [C:\BuildsNew\4\SharePrice\SharePrice_Dev\Sources\SharePrice\SharePrice.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\SharePointTools\Microsoft.VisualStudio.SharePoint.targets(378,5): error MSB4018: at Microsoft.VisualStudio.SharePoint.Tasks.ValidatePackage.OnCheckParameters() [C:\BuildsNew\4\SharePrice\SharePrice_Dev\Sources\SharePrice\SharePrice.csproj]
Any help would be much appreciated.

We usualy see this error if you only reference the DLL's using the registry described in (http://msdn.microsoft.com/en-us/library/ff622991.aspx) and/or didn't install everything correctly. In our case installing SharePoint 2010 completely (without configuring it) on the buildserver removes this error.

Related

msb4018: the "createvirtualdirectory" task failed unexpectedly

While deploying Biztalk application I am getting below error:
\Program Files (x86)---- for BizTalk 1.0.0\1.0\Deployment\Framework\BizTalkDeploymentFramework.targets(1829,5): error MSB4018: The "CreateVirtualDirectory" task failed unexpectedly.\r
C:\Program Files (x86)-----for BizTalk 1.0.0\1.0\Deployment\Framework\BizTalkDeploymentFramework.targets(1829,5): error MSB4018: System.Runtime.InteropServices.COMException (0x80070003): The system cannot find the path specified.\r
C:\Program Files (x86)----- for BizTalk 1.0.0\1.0\Deployment\Framework\BizTalkDeploymentFramework.targets(1829,5): error MSB4018: \r
"COMException (0x80070003): The system cannot find the path specified."
Since this is happening during app deployment via an MSI generated with the Deployment Framework, it appears that the physical folder for the virtual directory does not exist. Maybe it is not being packaged in the MSI at all, or maybe the location is different than the one specified in the .btdfproj.
I suggest you review the IIS sample application included with the Framework.

Why is the project file not found even though I am using an MSBuild task?

I created an Azure Devops build pipeline and I am trying to build my ASP.NET MVC and Angular hybrid site project on Bitbucket (git).
The project first gets checked out, and Nuget restores the necessary packages, however, I cannot get the .NET to build!
I've stumbled on this post here that basically advises against using the dotnet build task and recommended just using Visual Studio build or MSBuild tasks instead.
Nether are working for me though!
I tried VS2017-win2016 hosted agent, didn't work.
I tried Windows 2019 hosted agent, didn't work.
I am getting this error:
Bobby.ProjectA\Bobby.ProjectA.csproj(713,3): Error MSB4019: The imported project "C:\Program Files\dotnet\sdk\5.0.100\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\5.0.100\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\Bobby.ProjectA.Tests\Bobby.ProjectA.Tests.csproj,D:\a\1\s\Bobby.ProjectA\Bobby.ProjectA.csproj
D:\a\1\s\Bobby.ProjectA\BobbyProjectA\BobbyProjectA.sln.metaproj(0,0): Error MSB3202: The project file "D:\a\1\s\Bobby.ProjectA\BobbyProjectA\Bobby.ProjectA\Bobby.ProjectA.csproj" was not found.
D:\a\1\s\Bobby.ProjectA\BobbyProjectA\BobbyProjectA.sln.metaproj(0,0): Error MSB3202: The project file "D:\a\1\s\Bobby.ProjectA\BobbyProjectA\Bobby.ProjectA.Tests\Bobby.ProjectA.Tests.csproj" was not found.
Process 'msbuild.exe' exited with code '1'.
Since Ubuntu is faster, I also tried that, however, as expected Visual Studio build task fails with that since VS is not installed on the machine.
So I tried with MSBuild and that worked fine with Ubuntu, however, still getting same error that the project file was not found.
Project "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA/Bobby.ProjectA.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA.Tests/Bobby.ProjectA.Tests.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
Done Building Project "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln" (default targets) -- FAILED.
Build FAILED.
"/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln" (default target) (1) ->
(Build target) ->
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA/Bobby.ProjectA.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln.metaproj : error MSB3202: The project file "/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/Bobby.ProjectA.Tests/Bobby.ProjectA.Tests.csproj" was not found. [/home/vsts/work/1/s/Bobby.ProjectA/BobbyProjectA/BobbyProjectA.sln]
I pretty much exhausted my searches and not sure how to solve this.
Here are some screenshots that show my pipeline tasks:
I also thought maybe x64 architecture would have something to do with it, but that didn't resolve the issue.
I've stumbled on some other interesting posts like this one, but I'm not sure what adding the project to source control means in the answer given, considering my csproj files are already hosted in the repo and being checked out before any tasks run.
My project structure and .sln path (project):
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bobby.ProjectA", "Bobby.ProjectA\Bobby.ProjectA.csproj", "{12345FE4-4CB9-3245-9A45-DB9A4AF1DFEB}"
Based on my test, I could reproduce the similar issue when the wrong csproj file path is mapped in the .sln file.
You could check your .sln file -> project field.
For example:
File structure
The .csproj file is under the WebApplication2 folder, so the project relative path is WebApplication2\WebApplication2.csproj.
.sln file
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication2", "WebApplication2\WebApplication2.csproj", "{497AD76F-222C-4BEB-BDCB-401B0E80B5CE}"
EndProject
Update:
After discussion with Cataster, the import Project issue can be resolved by specifying **/*.csproj in Msbuild task.
For example:

AWS CodeBuild. Could not load SDK Resolver

I've got a CodeBuild project that builds on an AWS Windows container (not a custom container), and I've started getting the following error when the app tries to build. Nothing has changed in my setup. It sounds like an issue with the build container, which as far as I know I don't have access to, and can't really do anything about? Has anyone come across this error before?
Error MSB4247: Could not load SDK Resolver. A manifest file exists,
but the path to the SDK Resolver DLL file could not be found. Manifest
file path 'C:\Program Files (x86)\Microsoft Visual
Studio\2017\BuildTools\MSBuild\15.0\bin\SdkResolvers\Microsoft.Build.NuGetSdkResolver\Microsoft.Build.NuGetSdkResolver.xml'.
SDK resolver path: C:\Program Files (x86)\Microsoft Visual
Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll

XAML MSBuild task XamlMarkupCompilePass1 fails in parallel MSBuild and throws error Access denied

We have several projects containing XAML UI and XAML workflow files. Since we enabled execution of MSBuild in parallel, with the flag /m the builds, from time to time we get an exception in the MSBuild task XamlMarkupCompilePass1
##[error]C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Xaml.targets(193,5): Error XC1000: XC1020: Build error occurred in the XAML MSBuild task: 'Could not load file or assembly 'file:///C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.Threading.ThreadPool.dll' or one of its dependencies. Access is denied.
This is just an example, it is also happening sometimes on NuGet packages and not only .NET framework assemblies.
What is our setup: We have build servers and on each we have at least 2 build agents.
What did we try out already:
Turning off build agents to have only one per server, still running MSBuild with /m --> failed with Access denied
Run msbuild without /m --> was successful, but not a solution because of too long running build
Try to use a hidden flag for MSBuild, to retry on access denied MSBUILDALWAYSRETRY --> this is only used for Copy MSBuild task and not the XAML msbuild task
Question: Is there a way to affect the MSBuild task XamlMarkupCompilePass1 somehow? or is there another solution than turning off parallel execution of MSBuild? I guess there is also a possibility that XamlMarkupCompilePass2 could fail as well but didn't see that.

How to create web deployment alone package using TFS

I just need to create Web Deployement package using TFS build and don't want to deploy it automatically in IIS.
I have added the below two parameters in Build Definition - > MSBuild Arguments
/p:CreatePackageOnPublish=true /p:DeployOnBuild=true
The probelm is I am not getting the ZIP file in drop location and getting the below error.
C:\Program
Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets
(1657): The "MapUriToIisWebServer" task failed unexpectedly.
System.Runtime.InteropServices.COMException (0x80005000): Unknown
error (0x80005000) at
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind() at
System.DirectoryServices.DirectoryEntry.get_IsContainer() at
System.DirectoryServices.DirectoryEntries.CheckIsContainer() at
System.DirectoryServices.DirectoryEntries.Find(String name, String
schemaClassName) at
Microsoft.Web.Publishing.Tasks.MapUriToIisWebServer.get_IisMajorVersion()
at Microsoft.Web.Publishing.Tasks.MapUriToIisWebServer.Execute() at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at
Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost
taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost
taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask,
Boolean& taskResult)
What could be the issue?
Now I am getting different error
error : Web deployment task failed.(Object of type 'manifest' and path 'e:\TFS\Dev\ApplicationName\Binaries\Release_PublishedWebsites\ApplicationName_Package\ApplicationName.SourceManifest.xml' cannot be created.)
error : Object of type 'manifest' and path 'e:\TFS\Dev\ApplicationName\Binaries\Release_PublishedWebsites\ApplicationName_Package\ApplicationName.SourceManifest.xml' cannot be created.
error : One or more entries in the manifest 'sitemanifest' are not valid.
error : Application '/ApplicationName' does not exist in site 'Default Web Site'.
I believe you just need to add the 'Package' target to your build for the web project.
/t:Build;Package
I've been using that target in my tfs build to generate the _PublishedWebsite folder with the package zip for a while now with success.
EDIT: Explanation of Package target
If you look at your csproj file for your web application as an XML file, you'll see that it includes the following
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
This includes a bunch of web targets into your build process. Crack this file open and at the bottom you'll see that it in turn includes
<Import Project="..\Web\Microsoft.Web.Publishing.targets" Condition="Exists('..\Web\Microsoft.Web.Publishing.targets')" />
This file contains the definition of the Web Deployment process for MSBuild. You'll see that it declares a variable to denote the "target" to invoke on a Deploy as being "Package"
<DeployDefaultTarget Condition="'$(DeployDefaultTarget)'==''">Package</DeployDefaultTarget>
If you read through this file further it will give you an idea of how Packaging and Deployment work under the covers and what the set of properties and targets are you can manipulate to customize your build.
Long story short though, if you call
msbuild yourwebapplication.csproj /t:Package /p:Configuration=Release
It should build you the web deployment package for the Release configuration of your app.
I had the same issue and the only thing that resolved it was this:
Open your IIS Management console
Go to your Default Web Site
Add new Application named 'ApplicationName'
Run msbuild again. It will work.
Possible duplicate of MSBuild DeployOnBuild=true not publishing
I had the same problem with Atlassian Bamboo, and this fixed it for me: From a machine with Visual Studio copy the contents of "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web" to the TFS Build server.