I created an episerver alloy project, which builds and runs fine in visual studio after setting up some nuget packages, and I can deploy to azure and run in azure from VS without issue.
I am now trying to get the build to work in pipelines.
Following the instructions, I added a "nuget restore" task, and pointed it at a NuGet.config.
This works.
Then it gets to the build stage, and gives:
D:\a\1\s\DxcAlloy.csproj(335,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.202\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.202\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" is correct, and that the file exists on disk.
I have no idea how to debug this. Some posts say that error can happen if you dont have visual studio installed, but I cant install visual studio on azure pipelines...
I removed the existing ".net restore" task, as it failed, and am guessing that just my nuget restore is all I need - this is a guess.
The pipeline "agent specification" is vs2017-win16
The project was created in VS 2019.
In desperation, I added a "Use .NET core" task, and set the version to the one which build is complaining is missing, i.e. 3.1.202.
This didn't help.
Any ideas?
If you build your project using dotnet build task. Below configuration in your .csproj file will be evaluated to C:\Program Files\dotnet\sdk\3.1.202\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets (What you see from the error)
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0</VSToolsPath>
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" />
Microsoft.WebApplication.targets usually exists in below location. That is why it errors out ...Microsoft.WebApplication.targets not found.
In Visual Studio 2017 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets"
In Visual Studio 2019 "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets"
The workaround for above issue is using Msbuid task or Visual Studio build task to build your projects. See below example:
- task: VSBuild#1
inputs:
solution: '**/*.csproj'
enabled: true
For your case, you also need to set agent specification to agent windows-latest. For visual studio 2019(v16.0) is only installed in agent windows-latest.
If you have to run your pipeline on agent "vs2017-win16" (only visual studio 2017(v15.0) is installed). You need to change the VSToolsPath in the .csproj file to <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0</VSToolsPath>
If you have to use dotnet build to build your projects. You can hard code the import path in csproj file as workaround.
<Import Project="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" />
Related
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
I'm trying to get VSTS to run my Mocha unit tests, similar to how I've got them running in VS 2017.
I'm installed the Node JS Tools for Visual Studio and VS Test Explorer (after a restart) picks up the tests, and runs them.
But I can't get a VSTS build task to run them ???
Tried going through the notes on NTVS about running tests in VSTS but no joy getting it to work.
Moved onto the section about troubleshooting, and seeing if I can run the tests using my local vstest.console.exe ...
So far trying to run vstest ...
Error: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\Node.js Tools\Microsoft.NodejsTools.targets" was not found
quick fix ... added a copy of directory ... C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\Node.js Tools ... to ... C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0
Error: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" was not found
quick fix ... added a copy of directory ... C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets ... to ... C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0
Error: Could not find a part of the path C:\Repos\smc\BasicAzureExpress\BasicAzureExpress\ntvs\TestFrameworks
quick fix ... amend .nsproj to VS 2017 ... <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion> and a directory \TestFrameworks under \ntvs
... and then have the error ... Error: Missing generic test framework
So I'm left puzzled as to why VS 2017 can run the tests, but vstest.console.exe won't
First, the VSToolsPath value is empty if running in command line, then uses $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) path, but there aren’t necessary files of nodejs tool.
You can modify it like this (change Community to Professional if you are using vs2017 Professional):
<!--<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>-->
<VSToolsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0</VSToolsPath>
Secondly, refer to these steps to run test on Hosted VS 2017 agent.
Modify project file (njsproj)
:
<!--<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>-->
<VSToolsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0</VSToolsPath>
Copy NodeJsTools content in C:\Program Files (x86)\Microsoft Visual Studio\2017[Community, professional or enterprise]\Common7\IDE\Extensions\Microsoft to your ntvs folder
Add these files to source control and check in changes
Queue build with Hosted VS 2017 agent.
Is there some way to add the Node JS Tools for Visual Studio (NTVS) test adapter to a VSTS hosted agent?
The Visual Studio docs on hosted agent mention "Node.js Tools 1.0 for Visual Studio 2015" in the list for the "Hosted" agent, but the "Hosted VS2017" has no mention of any Node.js Tools
So how can you use the test adapter?
refer to these steps to run test on Hosted VS 2017 agent.
Modify project file (njsproj)
:
<!--<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>-->
<VSToolsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0</VSToolsPath>
Copy NodeJsTools folder in C:\Program Files (x86)\Microsoft Visual Studio\2017\[Community, professional or enterprise]\Common7\IDE\Extensions\Microsoft to your ntvs folder
Add these files to source control and check in changes
Queue build with Hosted VS 2017 agent.
Build definition steps:
NPM install (Working folder: $(Build.SourcesDirectory)\NodejsConsoleApp1)
Visual Studio Test task (Test assemblies: NodejsConsoleApp1\NodejsConsoleApp1.njsproj; Search folder: $(System.DefaultWorkingDirectory); Test platform version: Visual Studio 2017; Path to Custom test adapters: NodejsConsoleApp1\ntvs
Yep there are similar question out there, but they are not related to VS 2017:
Visual Studio Build - Azure 2.9 SDK
MSBuild MSB4096 error with Azure SDK 2.9.1
I've recently upgraded from VS 2015 to VS 2017. On my local dev computer everything works fine and the Azure application (with Azure SDK 2.9.6) builds and starts.
But on the TeamCity server (MS Build Tools 2017 - Tool version 15.0) I get the following error:
MSB4019: The imported project "C:\Program Files (x86)\Microsoft
Visual
Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Windows
Azure Tools\2.9\Microsoft.WindowsAzure.targets" was not found. Confirm
that the path in the declaration is correct, and that the
file exists on disk.
The build server/MSBuild tries to find the Microsoft.WindowsAzure.targets in the directory:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Windows Azure Tools\2.9\
But it is actually in the directory:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\[VisualStudioVersion]\MSBuild\Microsoft\VisualStudio\v15.0\Windows Azure Tools\2.9\
[VisualStudioVersion] can have the following values "Community", "Professional" ,"Enterprise"
Yes, I've the build tools installed (https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15 ).
Yes, I already copied the whole Windows Azure Tools folder to BuildTools\MSBuild\Microsoft\VisualStudio\v15.0, but then I get another error in my F# project:
MSB4057: The target "GetTargetFrameworkProperties" does not exist in
the project.
It seems like the new MS Build Tools 2017 doesn't work properly with Windows Azure. Are there any workarounds yet? Or is the only option to switch back to an older MSBuild?
The new standalone BuildTools currently don't support Windows Azure targets.
So if you want to use the new MSBuild 2017 with Azure SDK you have to install a full VS 2017 installation on your build server.
Note: You may have to restart the TeamCity (agents) in order to recognize the MSBuild path. After running a build you can see the used MSBuild paths in the tab 'parameters':
MSBuildTools15.0_x64_Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\[VS_VERSION]\MSBuild\15.0\bin\amd64
MSBuildTools15.0_x86_Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\[VS_VERSION]\MSBuild\15.0\bin
[VS_VERSION] can be Community, Professional or Enterprise
I still got the GetTargetFrameworkProperties error from the F# project, this was resolved by adding the flag:
/p:VisualStudioVersion=15.0
to the MSBuild task.
For more information see https://github.com/Microsoft/msbuild/issues/1888
How can I publish my asp.net web api project created in Visual Studio 2015 which has a webjob to Azure using teambuild in TFS 2012?
The problem seems to revolve around msbuild. Locally and on the build machine, whenever I explicitly use the msbuild in C:\Program Files (x86)\Microsoft Visual Studio 14.0 it will work. When I use C:\Windows\Microsoft.NET\Framework64\v4.0.30319\, it gives me the the following output explaining that the deployment is unpublishable.
Target "_DeploymentUnpublishable: (TargetId:3)" in file "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets" from project "{poath}WebApi.csproj" (target "Publish" depends on it):
Task "Message" (TaskId:4)
Task Parameter:Text=Skipping unpublishable project. (TaskId:4)
Skipping unpublishable project. (TaskId:4)
Done executing task "Message". (TaskId:4)
When I queue a build from TFS I use the following arguments,
/t:Publish /ToolsVersion:14.0 /p:VisualStudioVersion=14.0 /p:ToolPath="C:\Program Files (x86)\MSBuild\14.0\Bin" /p:DeployOnBuild=true /p:PublishProfile=azureProfile.pubxml /p:Username=$user /p:Password=password
I never found a solution to this, but I was able to get the following hack to work.
Create a csproj file
Add a new <Target> like below
<Target Name="PushPackages">
<Exec Command=""C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" {WebApiWithWebjob}.csproj /p:DeployOnBuild=true;PublishProfile=Dev.pubxml;VisualStudioVersion=14.0;Password={password}" />
</Target>
Add the csproj file as the last item to build in the build definition