Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What could I be doing wrong with my msbuild argument?

Tags:

msbuild

I have an msbuild argument

/t:Project.HQ.Web /p:DeployOnBuild=true /p:WebPublishMethod=Package 
/p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true 
/p:PackageLocation="$(build.artifactstagingdirectory)\\"

in my Azure DevOps Build pipeline for Solution Build.

I get an error that says

Agent job 1: "Code\AnotherMutliProjSolution.sln(0,0): Error MSB4014: The build stopped unexpectedly because of an internal failure. System.ArgumentException: The name "Project.HQ.Web" contains an invalid character ".". at Microsoft.Build.Shared.ErrorUtilities.ThrowArgument(Exception innerException, String resourceName, Object[] args) at Microsoft.Build.Construction.ProjectTargetElement.set_Name(String value) at Microsoft.Build.Construction.ProjectTargetElement.CreateDisconnected(String name, ProjectRootElement containingProject) at Microsoft.Build.Execution.ProjectTargetInstance.ToProjectTargetElement(ProjectRootElement rootElement) at Microsoft.Build.Execution.ProjectInstance.ToProjectRootElement() at Microsoft.Build.Construction.SolutionProjectGenerator.CreateSolutionProject(String wrapperProjectToolsVersion, Boolean explicitToolsVersionSpecified) at Microsoft.Build.Construction.SolutionProjectGenerator.Generate() at Microsoft.Build.Execution.ProjectInstance.GenerateSolutionWrapper(String projectFile, IDictionary2 globalProperties, String toolsVersion, ILoggingService loggingService, BuildEventContext projectBuildEventContext, IReadOnlyCollection1 targetNames, ISdkResolverService sdkResolverService, Int32 submissionId) at Microsoft.Build.Execution.ProjectInstance.LoadSolutionForBuild(String projectFile, PropertyDictionary1 globalPropertiesInstances, String toolsVersion, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext projectBuildEventContext, Boolean isExplicitlyLoaded, IReadOnlyCollection1 targetNames, ISdkResolverService sdkResolverService, Int32 submissionId) at Microsoft.Build.Execution.BuildManager.LoadSolutionIntoConfiguration(BuildRequestConfiguration config, BuildRequest request) at Microsoft.Build.Execution.BuildManager.HandleNewRequest(Int32 node, BuildRequestBlocker blocker) at Microsoft.Build.Execution.BuildManager.IssueRequestToScheduler(BuildSubmission submission, Boolean allowMainThreadBuild, BuildRequestBlocker blocker)" Review

I have tried having a my target set as 'Project.HQ.Web' and "Project.HQ.Web". I still run into the same issues.

like image 833
Dara Oladapo Avatar asked Dec 23 '22 23:12

Dara Oladapo


1 Answers

You need to replace the . with underscores to build the generated solution targets:

msbuild /t:Project_HQ_Web

See the following part of How to: Build specific targets in solutions by using MSBuild.exe

Specify the target after the -target: switch in the format <ProjectName>:<TargetName>. If the project name contains any of the characters %, $, @, ;, ., (, ), or ', replace them with an _ in the specified target name.

like image 64
Martin Ullrich Avatar answered Jan 01 '23 15:01

Martin Ullrich