setup teamcity with .core, run command fails - .net-core

I am trying to migrate from Jenkins to Teamcity 2018
So far I have 4 build steps:
Dotnet restore
dotnet build
dotnet run
dotnet test
When teamcity runs 3rd step, it fails.
it tries to run :
dotnet.exe run --project .\Prime.csproj #D:\TeamCity\buildAgent\temp\agentTmp\5d23e7ecee784cabb12baefd7175c67d.rsp
and it gives error
Unhandled Exception: System.FormatException: Unrecognized argument format: '#D:\TeamCity\buildAgent\temp\agentTmp\5d23e7ecee784cabb12baefd7175c67d.rsp'.
I think, it because dotnet cli doesn't accept the # part..
Have anyone seen such error before?
Solution has 2 projects: Prime (the main code) and a tests project with all the tests. The tests project runs just with with 'dotnet test' command
Using dotnet core 2.0 .

So the only way forward which I found is to run .core app in Docker.
So, you need to publish the app to a folder and then put that code into a docker image and then set up your test project to run against docker instance of the app.

Related

Azure Devops BUild scripts Are Restore Build and Test Required

In Azure Devops for a .Net core application.
I have three steps
dotnet restore
dotnet build
dotnet test
But if I simply run dotnet test that forces a restore and build. Is there any reason to have the first two steps?
You can use them as follows:
dotnet restore
dotnet build --no-restore
dotnet test --no-build
In this way, you will speed up your build as it can use result of the previous command.
This is default behavior so you don't need to always run all commands to run dotent test for instance. It is convinient and still possible to opt-out from thah behavior.

VSTS dotnet run step does not find build from previous step

I have the following successful dotnet build release pipeline step configured:
Task version: 2.*
Display name: dotnet build
Command: build
Path to project(s): **/AppConsole.csproj
Arguments:
It is immediately following by a failing dotnet run step:
Task version: 2.*
Display name: dotnet run
Command: run
Path to project(s): **/AppConsole.csproj
Arguments:
Which exits with the message:
[command]C:\agent_dply\_work\_tool\dotnet\dotnet.exe run C:\agent_dply\_work\r40\a\Testing\Tester\AppConsole.csproj
Couldn't find a project to run. Ensure a project exists in C:\agent_dply\_work\r40\a.
Or pass the path to the project using --project
##[error]Error: The process 'C:\agent_dply\_work\_tool\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : C:\agent_dply\_work\r40\a\Testing\Tester\AppConsole.csproj
How do I tell the dotnet command where the project is when running under VSTS? I've tried, as it recommends, using the --project flag, but it gives similar errors.

TeamCity - Building dotnet core web api project using cake script

Running Cake Build script on my local machine works fine but when same script is run on TeamCity, the following error appears: Nuspec file does not exist in package.
Any idea what could have caused this error?
I spent two days due to this error
On dotnet build --configuration Release in TeamCity PowerShell, always got this error
error NU5000: Nuspec file does not exist in package
After deleting this folder, everything worked C:/Users/teamcity_user/.nuget
I add an additional step on top of my build steps which is a command line custom script
dotnet nuget locals --clear all

Why does dotnet run launch 2 processes?

When I run my dotnet core 2 app from my PowerShell I always see 2 processes launched.
This is annoying as in Visual Studio 2017 I cannot "reattach" a debugger as there are always 2 processes with the same name "dotnet".
Any way to change this?
dotnet run is a development command that builds the project and queries the project for the actual command to run. It then launches the program described in the program - which may be a dotnet some.dll or someapp.exe depending on the program type.
To work around your issue, run a command like
dotnet bin\Debug\netcoreapp2.0\mapp.dll
directly to avoid process noise.
You can also chain a build command before it so you can rebuild the project on changes and still have the process that runs msbuild terminate:
dotnet build; dotnet bin\Debug\netcoreapp2.0\mapp.dll

VSTS msdeploy.exe error: ERROR_USER_NOT_AUTHORIZED_FOR_CONTENTPATH

I'm trying to create a release definition inside VSTS to deploy my ASP.NET Core 2.0 app on my production server.
I'm using the MSDeployAllTheThings extension: https://marketplace.visualstudio.com/items?itemName=rschiefer.MSDeployAllTheThings
I'm able to deploy inside Visual Studio using the same configuration...
VSTS Config (not working)
VSTS Error
Visual Studio Config (working)
Do you guys have any ideas how to do that?
I had the same problem with deployment to smarterasp.net and was able to setup things for Web Deploy:
Your Dotnet Build task could create deployment package with necessary files like [YourProject].deploy.cmd, [YourProject].zip and etc. For this you could use next Arguments in your Build Task:
--configuration $(BuildConfiguration) /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\"
Add "Batch script" task and set path to your [YourProject].deploy.cmd in Path field and also in your Arguments:
/y /m:$(SmarterAspNet.PublishUrl) -AllowUntrusted /u:$(SmarterAspNet.UserName) /p:$(SmarterAspNet.Password) /a:Basic "-setParam:name='IIS Web Application Name',value='$(SmarterAspNet.SiteName)'" -enableRule:AppOffline
With this two main DevOps tasks I was able to deploy my app to smarterasp.net
About MSDeployAllTheThings task: I removed it because it is not needed for me anymore
Not familiar with smarterasp.net. But this should be an issue with that site.
If you run the same msdeploy command from your local machine manually, you will get the same error message. We didn't see this error when use the same command to deploy to some other host instead of smarterasp.net. And if you add "-verbose" in the command, you will get a more detailed information which indicates that the command failed to adding the virtual path:
When you deploy your project from VS, it use the manifest file and source folder directly rather than "package" method. So you'd either contact smarterasp.net for help or use the same deploy method as Visual Studio or some other deploy method like FTP.

Resources