I would like to use a gulp task to compile and publish my ASP.NET application and integrate it in my overall release. I tried to find something via google and on StackOverflow, but I was not successful. Visual Studio (2015) is also not very helpful, as it does not show which commands it uses (if this is not an internal process).
I would like to get the same output as selecting my project -> Publish... (see image)
Is this possible somehow? Has anybody automated this or do I have to use the TFS build system to do it? Or does somebody know if I can use VisualStudio on my command line to automate the process?
EDIT:
It is currently an asp.net 4.5.1 application.
I found a solution, thanks to whoever voted for this question, I forgot about it.
Here is my example:
gulp.task("publishaspdotnet", (done: DoneCallback) => {
const gatewayBuildSolutionName = "My.sln"; // maybe also .csproj possible
exec("msbuild " + gatewayBuildSolutionName + " /p:DeployOnBuild=true /p:PublishProfile=localrelative /p:Configuration=Release /p:Platform=\"" + target + "\"", logConsoleOutput).on("exit", () => {
gutil.log("Really done --------------------------------------");
done();
});
});
});
Here are the steps:
Create a publish profile for your ASP.NET project (right click on your project -> publish...)
You can edit the profile, just click on "show all folders" in your solution explorer, go to publish profiles and edit your profile to deploy relative to the .csproj file which the pubxml file belongs to. The publishUrl tag is the place your code gets published to (if you set to local)
Write your gulp task and use msbuild to build. Use the switches as shown in the example above and reference your publish profile there. Now publish will be executed
Related
The razor view formatting is so bad
even when I tried ctrl k + ctrl d
the page is so missed up
any help, please!
#if (item.Details.Length > 10)
{
#item.Details.ToString().Substring(0, 10) }
else
{
#item.Details}
You can enable the new Razor editor first, and then restart VS.
New experimental Razor editor for Visual Studio
Then you can choose Edit->Advanced->Format Document.
✎[Edit]
You can try the following methods:
Check whether three-party plug-ins are installed.
If there are three-party plug-ins installed, temporarily disable them, and then test it.
You can try reset VS settings.
https://learn.microsoft.com/en-us/visualstudio/ide/environment-settings?view=vs-2019#reset-settings
Change the fourth step to select the General option.
Repair VS (repair in VS Installer)
Create a new project and check if the same problem occurs.
Clean up the program /project/VS cache, then restart VS and try again.
The project is cached in the solution/project folder,you need to delete the bin, obj and .vs files.
VS is cached in this path: C:\Users[user name]\AppData\Local\Microsoft\VisualStudio\16.0_XXXXXXXXX, delete all ComponentModelCache folder.
Give feedback to the VS product group from VS-> Help-> Send Feedback-> Report a Problem...
I have set up continuous deployment from a Visual Studio Online Git repository to an Azure Web App.
What is the best way to run acceptance/smoke tests on the website after a build is triggered and deployment has completed?
I have already tried POST_DEPLOYMENT_ACTION (How to add a custom post deployment script to azure websites?), but this seems to get ignored.
I also had a look at the Kudu PostDeployment hook (https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks), which appears overly hacky.
I am deploying a standard ASP.NET 4 MVC site by the way. Any help appreciated.
What is hacky about the PostDeployment hook?
An alternative to that could be to subscribe to the PostDeployment hook from the Kudu/SCM site
POST /api/hooks
{
"url": "http://www.callback.com/callback",
"event": "PostDeployment",
"insecure_ssl": false (set to true to ignore https certificate check, for test purposes only)
}
That would give you a POST like below on the specified URL when deployment is done:
{
"id": "cd5bee7181e74ea38a3522e73253f6ebb8ed72fb",
"status": "success", (could be pending, building, deploying, failed, success)
"author_email": "someone#somewhere.com",
"author": "Some One",
"message": "My fix",
"deployer": "Some One",
"start_time": "2013-06-06T01:24:16.5873293Z",
"end_time": "2013-06-06T01:24:17.63342Z"
}
More info here on kudu github wiki
What I ended up doing was customizing the build process to add a RunScriptTask at the end, which invokes my tests.
You can pass build parameters to the RunScriptTask like so:
"-username user#example.org -password test123 -environment " + DeploymentSettings.GetValue(Of String)("ProviderHostedDeploymentEnvironmentName")
If you edit the build definition from Visual Studio -> Team Explorer -> Builds, there is a tab on the left called Process that breaks down the build steps. If you click Show details at the top, there is an option to download the XAML build process template. You can customize this as you wish and then create a new build process template from that file. (Note that XAML build process template file must be pushed to the remote repository beforehand)
The question is a follow up to this one: Generate Web.Debug config which could be debugged](Generate Web.Debug.config which could be debugged)
I have defined a transformation for web.debug.config. During compilation I see the following:
Transformed Web.config using C:\data\Main\WebRole\Web.Debug.config into
C:\data\Main\obj\obj\x64\Debug\WebRole.csproj\TransformWebConfig\ [...]
transformed\Web.config.
Checked Web.config in the specified location - it is correct (transformation succeeded)
But when I start the service in the azure emulator I get an alert that
Why does it happen? Looks that incorrect web.config is taken. Where should I specify the location of correct (transformed) file?
The key thing to realise with web.config Transforms (and is mentioned in the answer to your linked question) is that they are only part of the story.
When you build your sources, the transformed web.config file is built into the /obj/ folder, ready for deployment.
It is only the act of deploying your solution somewhere that puts the transformed config file into use - as noted in the docs:
When you deploy the Web application by using the selected build configuration and by using either a deployment package or one-click publish, the Web.config file is transformed according to your specifications.
How are you running the application after you build it? You need to publish or deploy it using one of the built in mechanisms that support web transforms to see those changes on your site.
If you are running the emulator against the original source files, they won't see the transformed web.config file - which is why typically the debug build doesn't have any transforms and you then turn off debugging with your Release build which is then deployed to production.
As you're trying to test this in the emulator you should be able to do the following:
In the Solution Explorer, ensure you've selected a file within the project that runs in the emulator.
From the Build menu, select "Publish [Project Name".
In the Publish Wizard, create a new "Profile" using the "Custom" publish target.
In the "Connection" pane select "File System" as the publish method, and give it a suitable target location.
In the "Settings" pane choose the appropriate configuration (in your case probably "Debug"), and set any other options that you'd like.
Then press "Publish", and the project should be built, and then deployed to the new file location.
You should then be able to start the emulator from this newly published location, which will be using your transformed web.config.
I have found this solution and it works perfectly
https://translate.google.co.il/translate?hl=en&sl=de&tl=en&u=http%3A%2F%2Fwww.sascha-dittmann.de%2Fpost%2FWebConfig-Transformation-im-Windows-Azure-Compute-Emulator.aspx&anno=2
I'm struggling to get web.config transformations working with automated builds.
We have a reasonably large solution, containing one ASP.NET web application and eight class libraries. We have three developers working on the project and, up to now, each has "published" the solution to a local folder then used file copy to deploy to a test server. I'm trying to put an automated build/deploy solution in place using TFS 2010.
I created a build definition and added a call to msdeploy.exe in the build process template, to get the application deployed to the test server. So far, so good!
I then tried to implement web.config transforms and I just can't get them to work. If I build and publish locally on my PC, the "publish" folder has the correct, transformed web.config file.
Using team build, the transformation just does not happen, and I just have the base web.config file.
I tried adding a post-build step in the web application's project file, as others have suggested, similar to:
<target name="AfterBuild">
<TransformXml Source="Web.generic.config"
Transform="$(ProjectConfigTransformFileName)"
Destination="Web.Config" />
</target>
but this fails beacuse the source web.config file has an "applicationSettings" section. I get the error
Could not find schema information for the element 'applicationSettings'.
I've seen suggstions around adding arguments to the MSBuild task in the build definition like
/t:TransformWebConfig /p:Configuration=Debug
But this falls over when the class library projects are built, presumably because they don't have a web.config file.
Any ideas? Like others, I thought this would "just work", but apparently not. This is the last part I need to get working and it's driving me mad. I'm not an msbuild expert, so plain and simple please!
Thanks in advance.
Doug
I just went through this. Our build was a bit more complicated in that we have 8 class libraries and 9 web applications in one solution. But the flow is the same.
First off get rid of your after build target. You won't need that.
You need to use the MSDeployPublish service. This will require that it be installed and configured properly on the destination server. Check the following links for info on this part:
Note that the server in question MUST be configured properly with the correct user rights. The following sites helped me get that properly set up.
http://william.jerla.me/post/2010/03/20/Configuring-MSDeploy-in-IIS-7.aspx
http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html
How can I get TFS2010 to run MSDEPLOY for me through MSBUILD?
The next part requires that your build definition have the correct MSBuild parameters set up to do the publish. Those parameters are entered in the Process > 3.Advanced > MS Build Arguments line of the build definition. Here's a hint:
(don't change the following for any reason)
/p:DeployOnBuild=True
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=False
/p:MSDeployPublishMethod=WMSVC
/p:SkipExtraFilesOnServer=True
/p:AllowUntrustedCertificate=True
(These control where it's going)
/p:MSDeployServiceUrl="https://testserver.domain:8172/msdeploy.axd"
/p:UserName=testserver\buildaccount
/p:Password=buildacctpassword
/p:DeployIisAppPath="MyApp - TESTING"
Obviously the user will have to be configured in IIS on the target server to be allowed access to that axd (see previous links). And the IisAppPath is the name of the website on the target server.
You won't have to do anything special for the config transformations as the build itself will take care of that for you. Just have the correct setting in the line at Process > 1. Required > Items to Build > Configurations To Build.
Instead of trying to do the deploy by adding tasks myself into the build process template, I followed advice in Vishal Joshi's blog post here.
Now the entire project is built and deployed and the web.config transformations work also. Brilliant!
I now have another problem to solve! The web application references web services and the build process results in an XmlSerializers dll. However, although this is built OK, it does not get deployed to the web host. I think this needs a new post!
Doug
I am very much new to the Continous Integration. Could anyone please let me know whether we could build a website using MSbuild?
You can build a Web Site project using the AspNetCompiler MSBuild task.
http://msdn.microsoft.com/en-us/library/ms164291.aspx
Your MSBuild file might look something like this:
<Project
xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets = "PrecompileWeb">
<Target Name = "PrecompileWeb">
<AspNetCompiler
VirtualPath = "DeployTemp"
PhysicalPath = "C:\ccnet\myProject\WebSite"
TargetPath = "C:\ccnet\myProject\PreCompiled"
Force = "true"
Debug = "true"
Updateable = "true"/>
</Target>
</Project>
And then within your ccnet.config, you would add something like the following in the tasks block for your project:
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\ccnet\myProject\</workingDirectory>
<projectFile>C:\ccnet\myProject\myproject.msbuild</projectFile>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
If you have an SLN file for the Web Site, then you can use the following command:
msbuild YourSolutionFile.sln
Yes, you can - even with a "website".
What you need to do is add the "Web Deployment Project" and set it up so it will grab all the files from the website, compile them, and using something like WiX, you can create an installer for the files to be able to easily deploy your web site and all its files needed to a customer's computer.
Marc
unfortunately, if you have chosen "Website" as the project type you cant. However, if you chose "Web Application" project type, you can use MSBUILD to build it. Once you have created the "web application" project, you can right click on it and select "Add Web Deployment Project" which will add a wdproj file to your solution and you can customize the settings in there.
You can provide this wdproj file to your ccnet config file for the project which can run this as per the schedule configured. i can probably give you teh appropriate nodes required to configure in cc.net config file by tomorrow once i am in the office