Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild arguments to generate files

notes: Visual Studio 2017 solution with an MVC web app and several other projects, not all of which are referenced by the web app project. Until now Ive been using VS directly to publish to a test server, but I have moved things into VSTS and have a build & release definition setup but not working yet.

What im trying to achieve, is to get my (hosted) VSTS build agent to produce the published files that my (on-prem) release agent can simply copy to its target destination. So, Im trying to test the MS build step locally from the VS command line so as to get the files produced and note the path they are at. Maybe Im making this more complicated that it needs to be?

These options will create a single zipped archive and its associated files and place it into the artefact staging dir. Is there a way to simply publish the files WITHOUT putting them in an archive - and directly into the artefact staging dir?

Visual Studio Build

MSBuild parameters

/t:My_MVCWeb_Project_Name /p:DeployOnBuild=true 
/p:WebPublishMethod=FileSystem /p:PackageAsSingleFile=true 
/p:SkipInvalidConfigurations=true 
/p:PackageLocation="$(build.artifactstagingdirectory)\\"

In my release using on-prem agent), I have a "copy files" task, with the destination as the unc path where the IIS app is located. However, that will just copy over the archive. So how can I just copy the files as if I was using a publish profile, straight to the app directory?

[update2 - still getting zip file produced ]

MSBuild my_solution_name /t:"my_project_name" /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:SkipInvalidConfigurations=true /p:PackageLocation="D:\temp\local-dev-build-dir"

[ update 3 ] Trying these from the command line as a test, but nothing is generated

msbuild D:\app_dir>MSBuild my_solution_name.sln /t:"my_web_proj_name" /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="D:\temp\app_build_dir\\" 
/p:DeployDefaultTarget=WebPublish  
like image 596
bitshift Avatar asked May 23 '18 18:05

bitshift


People also ask

How do I set environment variables in MSBuild?

Click on System and Security and then on System. In the left pane, click on Advanced system settings. At the very bottom of the pop up, click on Environment Variables. Edit the Path variable and append the folder's path that contains the MSBuild.exe to it (e.g., ;C:\Windows\Microsoft.NET\Framework64\v4.

How do I create a SLN file in MSBuild?

At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute. Specify the target after the -target: switch in the format <ProjectName>:<TargetName>.

How do I set properties in MSBuild?

MSBuild lets you set properties on the command line by using the -property (or -p) switch. These global property values override property values that are set in the project file. This includes environment properties, but does not include reserved properties, which cannot be changed.


1 Answers

Using these MSBuild Arguments instead:

/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\" /p:DeployDefaultTarget=WebPublish
like image 142
starian chen-MSFT Avatar answered Oct 22 '22 10:10

starian chen-MSFT