Long story short, I was able to build a bitbucket .NET/MVC/Angular project successfully on windows 2019 azure hosted agent, as well as ubuntu agent. The reason I want to build it on ubuntu is because I noticed the build time is way faster than that of the windows agent, which makes sense considering the platforms.
I am facing this warning on Ubuntu 20 azure hosted agent:
warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.IdentityModel.Services". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
I dont get this warning on the windows 2019 agent, and i see there is a reference already included in the .csproj
file:
<Reference Include="System.IdentityModel.Services" />
and the following packages in packages.config
file
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.2.4" targetFramework="net471" />
<package id="Microsoft.IdentityModel.Logging" version="5.2.4" targetFramework="net471" />
<package id="Microsoft.IdentityModel.Protocols" version="5.2.4" targetFramework="net471" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="5.2.4" targetFramework="net471" />
<package id="Microsoft.IdentityModel.Tokens" version="5.2.4" targetFramework="net471" />
While the build is working just fine, Im curious to resolve this warning on Ubuntu agent, since its not showing up on windows 2019 agent.
screenshot of my build pipeline so far:
Figured it out thanks to this post here:
Add this script/lines to the .csproj
file:
<Import Project="..\packages\Microsoft.NETFramework.ReferenceAssemblies.net471.1.0.0\build\Microsoft.NETFramework.ReferenceAssemblies.net471.targets" Condition="Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net471.1.0.0\build\Microsoft.NETFramework.ReferenceAssemblies.net471.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see https://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net471.1.0.0\build\Microsoft.NETFramework.ReferenceAssemblies.net471.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NETFramework.ReferenceAssemblies.net471.1.0.0\build\Microsoft.NETFramework.ReferenceAssemblies.net471.targets'))" />
</Target>
In addition you also need to add such content into the packages.config file:
<package id="Microsoft.NETFramework.ReferenceAssemblies" version="1.0.0" targetFramework="net471" developmentDependency="true" />
<package id="Microsoft.NETFramework.ReferenceAssemblies.net471" version="1.0.0" targetFramework="net471" developmentDependency="true" />
and with that, it now runs on Ubuntu beautifully!!! Just check out these duration differences,
insane!