I have an ASP.NET MVC application written in .Net5.
This uses typescript files and I have NuGet package references to the following:
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.113" />
In my project I have:
- Folder called
node-modules(not pushed to Azure Devops) - bundleconfig.json
- gulpfile.js
- libman.json
- package.json (+ package-lock.json)
The package.json is:
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"devDependencies": {
"gulp": "4.0.2",
"del": "5.1.0",
"@types/bootstrap": "4.5.0",
"@types/google.visualization": "0.0.53",
"@types/jquery": "3.5.1",
"@types/jqueryui": "1.12.13",
"@types/jquery.datatables": "1.10.36",
"@types/jquery.ui.datetimepicker": "0.3.29"
}
}
When I compile in Visual Studio 2019 (latest) it compiles perfectly, everything works as expected.
I did however get in the Build Output (Information):
Package restore on project open is disabled. Change the npm package management settings in Project Properties to enable restore on project open.
I found the setting "Restore On Project Save" and changed this to true. That added the following to my csproj file:
<ProjectExtensions><VisualStudio><UserProperties appsettings_1qaf_1json__JsonSchema="https://gitpod.io/schemas/gitpod-schema.json" NpmRestoreOnProjectOpen="True" /></VisualStudio></ProjectExtensions>
I pushed this up to Azure DevOps, but when the agent builds it (some steps removed for clarity):
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
clean: true
I get the following error:
##[error]MyApp\Scripts\MyTypeScript.ts(13,9): Error TS2581: Build:Cannot find name '$'. Do you need to install type definitions for jQuery? Try
npm i @types/jquery.
So, the hosted agent is evidently not retrieving the types. I'm guessing I need to adjust my YAML file, but unsure how...
