6

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

15

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.

1
  • Thank you. I will explore this as an option. May 23, 2019 at 10:09
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
  • 2
    For solutions, MSBuild generates some special targets automatically, like -t:My_Project_name or -t:MySlnFolder\My_Project_Name:Clean May 22, 2019 at 19:14
  • (though personally I really don't like to use them) May 22, 2019 at 19:14
  • Thank you. I will explore this. May 23, 2019 at 10:09
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.