0

Need to run Xamarin.Android specific Unit Tests using Github Actions. Everything builds OK, but when I trying to dotnet test got the following error:

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\3.1.300\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\3.1.300\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk.

My script is:

 - name: UnitTests.Droid
      run: |
        dotnet restore
        nuget restore
        cd MobileAccess.UnitTests.Droid
        msbuild MobileAccess.UnitTests.Droid.csproj /verbosity:normal /t:Rebuild /p:Configuration=Release
        dotnet test

P.S. Solution-specific Unit Tests that do not affect Android run correctly

S. Koshelnyk
  • 478
  • 1
  • 5
  • 20
  • `dotnet` command is strictly for .NET Core projects today (.NET 5 will change that), so run the actual command line test tool instead. https://stackoverflow.com/questions/37792674/how-can-i-run-a-xamarin-uitest-from-the-commandline – Lex Li Jun 09 '20 at 13:46
  • @Lex Li I do not understand what exactly should I write instead of dotnet test because I am new one in this. XUnit in my case – S. Koshelnyk Jun 09 '20 at 15:39

1 Answers1

0

Was ably to run droid-specific unit tests in xamarin using:

    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v1
    - uses: nuget/setup-nuget@v1
    - uses: microsoft/setup-msbuild@v1.0.0  
    - name: UnitTests.Droid
      run: |
        nuget restore
        cd YourDroidUnitTestsCsprojDirectory
        msbuild YourDroidUnitTestsCsproj.csproj /verbosity:normal /t:Rebuild /p:Configuration=Release

    - name: Setup VSTest.exe
      uses: Malcolmnixon/Setup-VSTest@v3

    - name: VSTest
      run: |
        cd YourDroidUnitTestsDirectory
        cd bin
        cd Release
        cd netcoreapp3.0
        ls
        vstest.console MobileAccess.UnitTests.Droid.dll
S. Koshelnyk
  • 478
  • 1
  • 5
  • 20