Reputation: 596
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, IDictionary
2 globalProperties, String toolsVersion, ILoggingService loggingService, BuildEventContext projectBuildEventContext, IReadOnlyCollection
1 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, IReadOnlyCollection
1 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.
Upvotes: 6
Views: 4363
Reputation: 596
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
Upvotes: 0
Reputation: 100751
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.
Upvotes: 16
Reputation: 5452
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"
Upvotes: 2