Publish from VS works, xcopy of dotnet publish does not - iis

We have a dotnet core app, full framework referencing a ef6 lib. Running publish to IIS from VS2017 works fine.
When running the following from TFS2017 it does not work (ef6 strange errors)
nuget restore ***.sln
dotnet restore src/CoolApp/CoolApp.csproj
dotnet publish src/CoolApp/CoolApp.csproj --configuration release --output $(drop)
(when releasing) Copy everything from $(drop) to IIS website
Comparing content the exe is of course different, and exe.config also.
Any ideas what we've missed?

Are you using TFS 2017 Update1. If you are using TFS 2017 Update1, please don't use the .netCore(preview) step first. Try to use the tasks in this document about build your ASP.NET Core app to see if it works. Steps are:
Command Line(Dotnet restore).
Visual Studio Build. Cause your project is created in VS2017, select VS 2017 in this step to build.
Command Line(Dot restore). publish --configuration release --output $(drop)
Publish build artifacts.
When in release, copy the artifacts from $(drop).

Related

Is it possible to run vstest on a Linux machine via a release pipeline through Azure TFS

I am working on a release pipeline that should deploy our project artifacts and run tests over them.
The agent is on a Ubuntu machine.
So far I couldn't find a way to run tests over Ubuntu because as microsoft docs say we should install either the Visual Studio or Visual Studio Test Platform using an installer task on the agent.
The problem is neither of them are available on a linux OS , so I am a bit stuck here wondering if there is a third option that we can use to run our tests on this agent.
It depends on what type of your project is. If your project is .net core, you can try dotnet core cli task. Dotnet test can cross OS. If your project is .net fx, it cannot run on linux.
Run dotnet test command in .Net Core task
If you are using deployment group , you can run dotnet test command in a bash task and then use a Publish Test Result task to retrun trx files that Test has generated.

Unable to build Compiled Azure Function in VSTS (Error MSB4019)

I have created an Azure Function using the latest build of visual studio 2017 (15.3.1).
This build allows me to do the:
New Project > Azure Function App approach
This produces a .csproj (not a .funproj file) and it's doesn't come bundled with a website or anything. I've tried .Net 4.6 and 4.6.1 as the target framework and neither have worked.
I get the following error in VSTS:
C:\Users\Builder.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Publish.props
(13, 3)
C:\Users\Builder.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Publish.props(13,3):
Error MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Publish\Sdk\Sdk.Props"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
There is no node in my .csproj file so I am not sure where it is getting that from.
I'm using the latest NuGet option in VSTS, I'm using the Latest VS Version option as well.
The build steps are:
Get Sources
NuGet Restore
Build Solution (MSBuild.exe exited with code '1' every time)
Is there any way to build (and then release) compiled .Net functions in VSTS at the minute?
I was able to solve this by swapping the build agent from the "Default" group to the latest, "Hosted VS 2017" group, and that has compiled fine.
Looks like the machine is missing the latest dotnet cli. I'm not too familiar with VSTS build machines, but you'd need to get that on there somehow https://www.microsoft.com/net/download/core

Auto-deployment with continuous integration of .NET CORE fails because it cannot modify the file 'xxx.exe'

I have created a new ASP.NET Core Web Application. I'm using TFS (2015 Update 2) MS Build process to build and deploy my application to my Dev/QA server. I'm running my code with a Kesrel/IIS configuration on a window server.
My build Steps are:
Command Line: dotnet Restore -- restores my nuget packages
Command Line: dotnet build -c Dev -- builds my dev profile
Command Line: dotnet publish --framework netcoreapp1.1 --runtime win7-x64 --output "C:_work\dev\svc" --configuration DEV --no-build
Publish Build Artifacts: from that output folder in step 3 to my web server.
Problem:
The major problem I have is that the new core applications all run as console applications, so there is an 'xxx.exe' file running, in addition to the w3svc.exe IIS app running. When my Publish Build Artifacts steps runs, the process fails because the 'xxx.exe' file is in use, and cannot be modified.
So far as I can tell, you have to use the "dotnet" CLI to build and publish your CORE applications, and you cannot use the VS Build steps.
I've tried pointing my "dotnet publish" command to directly to the web server, but that has the same problem. You can see in my "dotnet publish" command I'm indicating a configuration to use (DEV). However even if I have DEV setup in VS to do a webdeploy, the "dotnet publish" command ignores that and either puts the code in a default publish location, or the location I specified in the command. So that doesn't work like the old .net framework did either.
My hosting team won't give me access to run remote powershell scripts to stop the IIS apps and console application, and I don't see any other build steps that would work to build the CORE application.
I'm on TFS 2015 Update 2. We're soon going to be on Update 3, but I don't know if that will give me feature to fix this either. If anyone know, I'd love to hear it!!
If I stop IIS app pools and make sure the console app is also stopped, my Build and Deploy steps above, work perfectly, but I don't want to have to manually stop IIS app pools every time before a build.
ASP.NET Core still respects the presence of an app_offline.htm file, so if you can copy a file with that name to the app destination on your server before step 4, and remove the file after step 4, the deployment should work. The ASP.NET Core module watches for this file and shuts down the hosting process (the .exe).
I'm sure you can run msdeploy tasks from VSTS, and msdeploy has a parameter to create an app_offline.htm file for you (although there is currently a bug in the ASP.NET Core module deployed to Azure where the file has to be all lower case letters). Msdeploy does work in deploying a published Core application to IIS.
Since stopping IIS app pools can solve the issue, you may try to install IIS Utilities to stop or start Application pool.

How to update .NET Core on Azure Web App?

I have my Azure Web App configured to deploy from a local git repository - I just push my changes to the Web App git repo and it builds and deploys the site.
I just updated to my ASP .NET Core site to: "version": "1.0.0-preview2-003133", previously it was 003131 which worked no problems.
I now get the response when doing the git push:
remote: GETSDKTOOLINGINFO : error : The project is configured to use .NET Core SDK version 1.0.0-preview2-003133 which is not installed or cannot be found under the path D:\Program Files (x86)\dotnet. These components are required to build and run this project. Download the version of .NET Core SDK specified in global.json or update the SDK version in global.json to the version that is installed.
I would prefer to update the .NET Core version on my Web App than downgrade, but how?
In case you are wonder how I have 3133 already: https://github.com/aspnet/Tooling/issues/801
You basically can not update the dotnet version on Azure. Currently the version of dotnet that is running is 003131. So you still have to use the previous version.
How are you building your release package?
I had this yesterday using a VSTS build process, when using the 'Visual Studio' build task it will fail with this error currently - changing your process to use the "CMD line" build task and "dotnet publish" allows the build to complete successfully.

How to determine if MSBUILD Arguments were executed for TFS Build Definition

I am using Team Foundation Service 2012, with a build controller hosted internally so I can deploy apps to our web servers. I setup the Build Definition, and am using the my Debug configuration, and have supplied the following MSBUILD arguments.
/p:DeployOnBuild=true /p:DeployTarget=MSDeployPublish /p:MSDeployPublishMethod=WMSVC /p:MSDeployServiceUrl=https://myserversname:8172/msdeploy.axd /p:AllowUntrustedCertificate=true /p:DeployIisAppPath="somesite.ourdomain.com" /p:Username=na\svc-users /p:Password=PASS /p:VisualStudioVersion=11.0
The solution builds just fine, I get no warnings, or errors. When I go my deployment server, the application is empty. I have setup the permissions to the web application folder, and inetsrv folder. I also installed/configured web deploy. If I am not getting any errors returned how can I tell what is going wrong with my Deployment? I have already checked the Event Logs on both the Build server, and the Deployment server, and neither have any errors or warnings. I can also do a publish from my dev machine and it works perfectly with the exact same parameters.
Copy these two folders, and their content, from your development environment to the build server:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications
These folders are a dependency which is caused by publishing through Visual Studio 2012. This dependency is referenced in the .sln file.
Unfortunately this means web deploy is failing silently.
Alternatively you could install Visual Studio on the build server but that would be a waste of a license.

Resources