I created a new ASP.Net core project and set it up in source control which publishes to Azure when I do a check-in. I was able to get everything setup correctly and it was working fine.
However, I then added a class library project to the solution and now instead of publishing my website project the MSBuild task is attempting to publish my class library which of course fails.
The line in the deployment command is:
"%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\MySolution.sln" /nologo /verbosity:m /p:deployOnBuild=True;AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false;publishUrl="%DEPLOYMENT_TEMP%"
And when that runs it first builds the models project which is fine:
D:\Program Files (x86)\dotnet\dotnet.exe build "D:\home\site\repository\MySolution.Models" --configuration Release --no-dependencies
But then it attempts to publish that project as well:
D:\Program Files (x86)\dotnet\dotnet.exe publish "D:\home\site\repository\MySolution.Models" --output "D:\local\Temp\PublishTemp\MySolution.Models71" --configuration Release --no-build
D:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Publishing.targets(149,5): error : Can not find runtime target for framework '.NETStandard,Version=v1.6' compatible with one of the target runtimes: 'win8-x86, win7-x86'. Possible causes: [D:\home\site\repository\MySolution.Models\MySolution.Models.xproj]
Which is the wrong project (it should be the web project). I can't seem to find any files that contain the settings for this or the setting in the solution file itself.
What do I need to do for this to publish the correct project?
I was able to solve this by doing it in two steps.
First remove the deployOnBuild=True and the publishUrl=[snip] from the msbuild command. This means this step will build the project but doesn't do any publishing.
Next add a new step that does the publish.
To do this I first created a new variable to hold the location of the dotnet.exe:
IF DEFINED DOTNET_PATH goto DotNetPathDefined
SET DOTNET_PATH=%ProgramFiles(x86)%\dotnet\dotnet.exe
:DotNetPathDefined
Then add the following to do the publish of the web project:
call :ExecuteCmd "%DOTNET_PATH%" publish "%DEPLOYMENT_SOURCE%\MySolution.Web" --framework netcoreapp1.0 --output "%DEPLOYMENT_TEMP%" --configuration Release --no-build
IF !ERRORLEVEL! NEQ 0 goto error
This then publishes all the files to the deployment temp folder which then get deployed using the KuduSync step.
Related
Trying to deploy the project with Azure Kudu (reading from a BitBucket repo) I get the following error in Deployment Center within Azure Portal...
This error happened with all the latest versions of Microsoft.Net.Compilers NuGet package. The only version that worked was 3.0.0 from 5 months ago.
Anyone knows what's the cause of this? Is Azure Kudu not yet updated?
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling .NET Web Application deployment.
MSBuild auto-detection: using msbuild version '14.0.23107.0 built by: D14REL' from 'D:\Program Files (x86)\MSBuild\14.0\Bin'.
Restoring NuGet package Microsoft.Net.Compilers.3.1.1.
GET https://api.nuget.org/v3-flatcontainer/microsoft.net.compilers/3.1.1/microsoft.net.compilers.3.1.1.nupkg
OK https://api.nuget.org/v3-flatcontainer/microsoft.net.compilers/3.1.1/microsoft.net.compilers.3.1.1.nupkg 937ms
Installing Microsoft.Net.Compilers 3.1.1.
Adding package 'Microsoft.Net.Compilers.3.1.1' to folder 'D:\home\site\repository\packages'
Added package 'Microsoft.Net.Compilers.3.1.1' to folder 'D:\home\site\repository\packages'
NuGet Config files used:
D:\local\UserProfile\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
D:\home\.nuget\
https://api.nuget.org/v3/index.json
Installed:
1 package(s) to packages.config projects
D:\home\site\repository\packages\Microsoft.Net.Compilers.3.1.1\tools\Microsoft.Managed.Core.targets(63,60): error MSB4086: A numeric comparison was attempted on "$(MSBuildVersion)" that evaluates to "" instead of a number, in condition "$(MSBuildVersion) >= 16.1.0". [D:\home\site\repository\MyCompany\MyCompany.csproj]
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\MyCompany\MyCompany.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d727f56aa60788";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="D:\home\site\repository\.\\"
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\84.10807.4030\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
### EDIT ###
I also opened an issue # Kudu GitHub repo.
I’ve had a similar issue with a kudu deployment and typescript versions. The basic issue seem to be that kudu is on its way out in favour of Azure DevOps so some dependencies of msbuild are becoming out of date. These are three options that might help you resolve the issue:
Switch to Azure DevOps - you’ll have access to various build agents and much more control over what they are capable of, but generally they’ll just be more up to date
Amend your build script - this is the script that kudu uses and you can customise it and then put it in source control, see this kudu doc for more info. Looks like you’re targeting msbuild 14 but I’m pretty sure 15 should be available and you can point your build script at this and/or make other tweaks
Process some of your build offline, ie before committing - this was my temporary solution with typescript, I was able to transpile to JavaScript and commit the js meaning I could disable typescript processing for kudu
It may also help to dig around in the targets file referenced in your log and trace back where the problem starts through the various msbuild conditions in that file. You can see all this by exploring via a command prompt in kudu.
I have an app that I'm trying to deploy to Azure using the Development Center. The app works great locally but when I check in my code and Azure starts the deployment process, it fails with the following message in reference to System.Xml.ReaderWriter.4.3.1:
error BC32210: Multiple assemblies with equivalent identity have been imported
The message is confusing because my packages.config only references the assembly once and the app builds fine locally.
How do I correct this problem?
Here's the full log entry:
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling .NET Web Application deployment.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin\amd64'.
Restoring NuGet package System.Xml.ReaderWriter.4.3.1.
GET https://api.nuget.org/v3-flatcontainer/system.xml.readerwriter/4.3.1/system.xml.readerwriter.4.3.1.nupkg
OK https://api.nuget.org/v3-flatcontainer/system.xml.readerwriter/4.3.1/system.xml.readerwriter.4.3.1.nupkg 300ms
Installing System.Xml.ReaderWriter 4.3.1.
Adding package 'System.Xml.ReaderWriter.4.3.1' to folder 'D:\home\site\repository\packages'
Added package 'System.Xml.ReaderWriter.4.3.1' to folder 'D:\home\site\repository\packages'
NuGet Config files used:
C:\DWASFiles\Sites#1asdffdsa__fb6e\AppData\NuGet\NuGet.Config
Feeds used:
D:\home.nuget\
https://api.nuget.org/v3/index.json
Installed:
1 package(s) to packages.config projects
vbc : error BC32210: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references. [D:\home\site\repository\DiocesanClaims\DiocesanClaims.vbproj]
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\DiocesanClaims\DiocesanClaims.vbproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d70fa465288676";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="D:\home\site\repository.\"
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\82.10503.3890\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
I'm not sure exactly what the issue was or why it was a problem but luckily, I didn't need the assembly in question. I uninstalled it from the list of Nuget packages and I was able to deploy fine after that.
I've got an Azure Resource Group-project (.deployproj) in Visual Studio which deploys fine. It is containing a DSC.ps1 file and a CustomScripts.ps1 file which is referenced by the template.json.
I want to deploy this project from TeamCity, but I can't find the way to build the project. During deploy Visual Studio outputs:
11:01:21 - Build started.
11:01:21 - Project "AzureResources.deployproj" (StageArtifacts target(s)):
11:01:21 - Project "AzureResources.deployproj" (ContentFilesProjectOutputGroup target(s)):
11:01:21 - Done building project "ESS.AzureResources.deployproj".
11:01:21 - Done building project "ESS.AzureResources.deployproj".
It seems it puts the DSC.ps1 file inside a zip-archive together with some dependencies before it runs the Deploy-AzureResourceGroup.ps1 which in turns does the deploy. The output of the build is put in bin/Debug/staging.
How can I perform the build from TeamCity/command line? Through msbuild?
I don't think the .deployproj has a deploy action, only build. To deploy you'd need an additional step in TeamCity to invoke the Deploy-AzureResourceGroup.ps1 and point it to the build output.
I am using Deploy azure app service to slot build step in Team Services, I want to be able to build my solution with PackageAsSingleFile set to False. However when I try to release the package with path to the artifact created I get "No packages found with specified pattern".
Do I need to create two artifacts, one as zip file and one as a package of files to be able to do what I want? I have tried different path to folders, but I get same error no matter.
Refer to these steps:
NuGet Installer task to restore package
Visual Studio Build task (Solution: ***.sln; Visual Studio Version: Visual Studio 2015; MSBuild Arguments: /p:DeployOnBuild=True /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:publishUrl="$(build.artifactstagingdirectory)\"; Platform: $(BuildPlatform); Configuration: $(BuildConfiguration))
Publish Build Artifacts (Path to Publish: $(build.artifactstagingdirectory); Artifact Name: drop; Artifact Type: Server)
Edit/create Release definition
Link artifact to previous build
Azure App Service Deploy (Package or Folder: $(System.DefaultWorkingDirectory)/**/drop)
Uncheck Publish using Web Deploy option
I used zip file, and Azure App Services Deploy task can be execute successfully.
For the related build definition, you can use below tasks:
Copy Files task:
Source Folder: $(Build.SourcesDirectory).
Contents: the project you want to deploy to Azure, such as ASPNETCoreProj\**.
Target Folder: $(Build.ArtifactStagingDirectory).
Archive Files task:
Root folder (or file) to archive: $(Build.ArtifactStagingDirectory).
Archive type: zip.
Archive file to create: $(Build.ArtifactStagingDirectory)/project.zip.
Publish Build Artifacts task:
Path to Publish: $(Build.ArtifactStagingDirectory).
Artifact Name: drop.
In the release definition, you can specify Package or folder as $(System.DefaultWorkingDirectory)\**\*.zip in Azure App Services Deploy task.
I am using NodejsTools in Visual Studio 2013, but can publish my project to Azure. When I build my file I get the following error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Node.js
Tools\Microsoft.NodejsTools.targets(115,5): error MSB4018: The
"AssignTargetPath" task failed unexpectedly.
System.IO.PathTooLongException: The specified path, file name, or both
are too long. The fully qualified file name must be less than 260
characters, and the directory name must be less than 248 characters.
Any clues on how I can fix this/get my node project to publish up to Azure?
Update 1: If I move the project to a root folder in my Windows C: drive, the build error goes away and build succeeds. However, if I try to publish, it fails and does not give a reason why:
------ Publish started: Project: MyProject, Configuration: Release Any CPU ------ Auto ConnectionString Transformed Web.config into
obj\Release\CSAutoParameterize\transformed\Web.config. Copying all
files to temporary location below for package/publish:
obj\Release\Package\PackageTmp.
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
I ran into the same problem. The paths created in the visual studio template are indeed too long to be uploaded on Azure. The paths are probably within your "node_modules" folder.
I solved this problem as follows:
Within the project folder, I deleted the folder "node_modules", containing all the modules needed to build your project. You can add these modules later, so no worries.
Open visual studio, reload the solution and publish your project again on your Azure account. Visual Studio probably doesn't return any errors now, since all paths are shorter than 240 characters.
Then, login on the Azure portal, open your web app and click on "add tiles" and add the console tile. Open the console tile and run the command "npm install". This command adds all dependencies within your project, hence adds the folder "node_modules" with all the modules needed for your project. You can see your project and work on them using the "Visual Studio Online Extension".
It’s difficult for troubleshooting if there is no error code.
I suggest you need check the <PropertyGroup> values such as <OutputPath>.</OutputPath> and so on in node.js project file which is end with .njsproj. Any information, please share it with me.
And in my test, I have to create a nodejs application via Azure Node.js application template so that I can publish it to Azure Web Apps.
You can try to create a new node.js app using Azure Node.js application and to check whether it can be published to Azure Web App. When succeed to publish app to Azure, you can copy your code into this project, then try to publish again.
Any concern, please let me know.