Web Deploy to Server with MSBuild - iis

I have a publish profile set up in a VS 2012 project. When I right click on the project in VS, select Publish and click on the [Publish] button, it publishes the project to the server using the settings provided in the Publish Profile.
When I use msbuild and the command line, with the following syntax:
msbuild.exe .\mvc.csproj /p:PublishProfile=DevServer
/p:DeployOnBuild=True /p:Password=MyPassword /p:AllowUntrustedCertificate=true
Then it builds the project, and gives me a message:
Package "mvc.zip" is successfully created as a single file at the following location: file:///c:/code/mvcsite/obj/Debug/Package
And then provides info on how to deploy the package.
How can I deploy from the command line? My ultimate goal is to run the deployment through TeamCity, and am right now trying to get my command line properties correct. However, the most that I can do from the command line right now is to create the deployment package, but not to run the actual deployment. How can I do both (preferably with one statement, to duplicate what happens in VS2012 when I deploy from there)?

Since you are building the .csproj you missed one important property
/p:VisualStudioVersion=11.0
This property was introduced in MSBuild 4.5 to facilitate project sharing between VS 2010 and VS 2012. A drawback; when building the .csproj you need to specify the value for this property. When building the solution file the value can be derived from the solution file version. Read more at my blog http://sedodream.com/2013/01/06/CommandLineWebProjectPublishing.aspx.

Related

Not able to execute selenium test cases via Azure Devops release pipeline

I am trying to configure and run selenium test cases from Azure Devops Release pipeline. I did configure Visual studio Test Platform installer followed by Visual studio test. However, while running the 'test task', its erroring out stating
2019-12-22T11:31:50.7602521Z ##[warning]No test sources found matching the given filter '**\*csproj'
Am I missing something here or not doing proper configuration?
My main test case is being written in .cs file and tried including it in path as well but still same error.
Can someone please guide me?
thanks,
Pankaj
You have to add the path to the assemblies - dll. cs files are not used here as they are not compiled.
Provide the search pattern in the Test files field
Example search pattern:
**\publish\Test.Project.Name.dll
!**\*TestAdapter.dll
!**\obj\**
Have you built your project? Since you said you can see only files which are .cs or .csproj. You should first build your project to generate .dll files which are used in your vstest test files.
You can add the Visual Studio Build Task above the Visual Studio Test Task, then choose your project(.csproj or .sln) in the Solution Tag.
After building, you will see the .dll files in your Artifact, then, as Jonah said, you need to specify the location of the .dll file in Test files.

How to create a x64 (instead of AnyCPU) build of .Net based Azure Cloud Service?

I'm using Azure 2.7.
I created a C# cloud service that only contains a single worker role. After it's done, the solution contains
A ccproj
A csproj
Both are using the setting of AnyCPU.
I then added the PropertyGroup "Debug|x64" and "Release|x64" into both projects. Also changed the default to x64 for both. As a result, an x64 build.
However, whenever I select "publish" on the "ccproj", I notice that it always builds AnyCPU instead of x64. I cannot find how to force it to build x64 for packaging and deployment.
I then edited both proj file again, and removed the PropertyGroup for "Debug|AnyCPU" and "Release|AnyCPU". After I did this, and when I tried to build x64 again, I got error as:
C:\Program Files
(x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(723,5):
error : The OutputPath property is not set for project
'AzureWorkerRoleExample.ccproj'. Please check to make sure that you
have specified a valid combination of Configuration and Platform for
this project. Configuration='Release' Platform='AnyCPU'. This error
may also appear if some other project is trying to follow a
project-to-project reference to this project, this project has been
unloaded or is not included in the solution, and the referencing
project does not build using the same or an equivalent Configuration
or Platform.
I could not figure out how to work around this error.
Any idea on how to force VS to make a x64 build of cloud service and deploy it?
One workaround I found is that: keep AnyCPU property groups, but also put
<PlatformTarget>x64</PlatformTarget>
in the group. Thus the AnyCPU assembly are actually targetting to x64. But this sounds hacky.
Any idea?
Thanks a lot!

Build multiple independent projects in the same solution in TeamCity

I have an MVC app in VS2013, and it has several related web/service projects, and one console app that is used for running SQL scripts against the database (it uses DbUP, to integrate with Octopus Deploy).
How can I generate NuGet Packages for both the web app and the console app?
I have created a separate Visual Studio (sln) step to build this project, but I get a missing reference error for the DbUp NuGet package. If I add a project reference to the web app, then the build is successful, but no artifact is generated. I would like to generate the NuGet package without adding the reference.
Well, this is embarrassing. Adding OctoPack NuGet package to my console app solved my problems.

How do I make sure TFS is using most recent Azure SDK?

I have a Visual Studio 2013/Azure SDK 2.3 solution with a WebRole ccproj project where I am trying to automate the build and packaging to a .cspkg file.
If I build the solution on my dev machine and then right-click project and do "Package" (with Cloud/Release) everything works fine.
However, on the TFS Build Controller machine, I get the following error:
C:\Builds\439\MyPortal\Dev-MyPortal\bin\Debug\ServiceDefinition.csdef: Cannot find the physical directory 'C:\Builds\439\MyPortal\MyGateway' for virtual path MyGateway/.
This seems to indicate that the TFS build server is using the old Azure SDK 1.7 (and before) behavior for site physicalDirectory declarations:
<Site name="SolovisPortal" physicalDirectory="..\..\..\SolovisPortal">
I have the above definition in my ServiceDefinition.csdef. Another problem is that it looks like the ServiceDefinition.csdef is being overwritten into the same place for all 4 of my ccproj projects in the Solution.
Note: The build works fine if I eliminate "/t:Publish /p:TargetProfile=Cloud" from the MSBuild arguments.
Really, all I want to do is create the cspkg file for 2 of the 4 ccproj in the solution (just want to "Package" as opposed to "Publish").
Update (4/9/2014)
I am able to build the Azure package from a command-line on my local machine using cspack:
cspack MyPortalAzure\bin\Release\ServiceDefinition.csdef /out:test.cspkg /useCtpPackageFormat
However, my cspkg is 18MB, but it I manually "Package" the cspkg through Visual Studio it is only 15MB. Is VS doing something special to compress the file?

create azure package with build

I was just upgrading my project from sdk 1.3 to 1.7 and I noticed that now when I build the application the package(cspkg) is not created with the build. I have go click on publish to create a package. Is there a way to tell VS to create a package everytime a build is triggered.
Also using msbuild is there a way to do the same thing. I have multiple projects under a solution, Most of which are just libraries and then there is this azure app. Is there a way to specify a single msbuild statement with params to tell the azure app to create the package as well as build the other projects. Also when I specify debug the debug package should be created and when I specify release switch the release package should be created.
How could I do the same thing on my build server as well where I have a .proj file which specifies the sln to build. How could I mention a switch to build the package there.
Thanks,
Kunal
You can configure CSPACK command (Be sure to have CSPACK.exe launched from SDK 1.7 Path otherwise you will get some schema related errors with SDK 1.6 project) as Post Build event in your Windows Azure Application Build settings. This way when you will build, after successful build CSPACK command will run and package your application. Same way you can configure your MSBuild configuration. I just tested and it worked for me.
Visit this MSDN article on packaging a cloud service to learn more.
You can do this using msbuild as well. See the Resolution section of this question.

Resources