My pre-build event:
copy /y $(ProjectDir)nuget.exe nuget.exe
nuget pack $(SolutionDir)..\bin\CertificateValidation_WinRT\CertificateValidation_WinRT.nuspec
nuget sources add -ConfigFile $(SolutionDir)..\NuGet.Config -Name PackageSourceWinRT -Source $(ProjectDir)bin\$(Platform)\$(Configuration)
dotnet add $(ProjectDir)CertificateValidation.WinRT.UnitTest.csproj package CertificateValidation_WinRT
nuget sources remove -Name PackageSourceWinRT -ConfigFile $(SolutionDir)..\NuGet.Config
copy, nuget pack, nuget sources add, these command run success. But "dotnet add" execute failed. Below is the output info of console:
- build 15-Sep-2022 04:01:00 Package source with Name: PackageSourceWinRT added successfully.
- build 15-Sep-2022 04:01:01 E:\VPN-CVNAT44-JOB1\src\src\Tests\Lenovo.CertificateValidation.WinRT.UnitTest\Lenovo.CertificateValidation.WinRT.UnitTest.csproj(134,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\6.0.301\Microsoft\WindowsXaml\v17.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\6.0.301\Microsoft\WindowsXaml\v17.0\Microsoft.Windows.UI.Xaml.CSharp.targets" is correct, and that the file exists on disk.
My visual studio 2022 is installed on D: , I search for Microsoft.Windows.UI.Xaml.CSharp.target
https://i.stack.imgur.com/hLrG5.png
And my .csproj include below node
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
I think the project profile is OK. Then I search for Microsoft.Common.props
https://i.stack.imgur.com/hcrtZ.png
I doubt "dotnet add" use a wrong Microsoft.Common.props. Isn't it?