7

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.

3 Answers 3

16

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I will explore this as an option.
2

From the documentation, /t is used to build target of a project. There is no switch for the project itself.

You must use as command line:

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

3 Comments

For solutions, MSBuild generates some special targets automatically, like -t:My_Project_name or -t:MySlnFolder\My_Project_Name:Clean
(though personally I really don't like to use them)
Thank you. I will explore this.
0

I finally figured it out. What I did was instead of build the solution, I built the csproj file itself passing in the msbuild argument

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(build.stagingDirectory)\\ProjectHQWeb 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.