title: C#: My 1st Azure DevOps Pipeline ("Hello, World!") - "The type or namespace name 'System' could not be found"
body: <p>All I want (for now) is to create an Azure DevOps C# pipeline that runs <code>Helloworld.cs</code>.</p>
  
  <p>I created a <code>Helloworld.cs</code> &amp; <code>Helloworld.csproj</code> following <a href="https://docs.microsoft.com/en-us/visualstudio/msbuild/walkthrough-creating-an-msbuild-project-file-from-scratch?view=vs-2019" rel="nofollow noreferrer">this Microsoft KB</a>.</p>
  
  <p><strong>Helloworld.cs</strong></p>
  
  <pre><code>using System;
  
  class HelloWorld
  {
      static void Main()
      {
          Console.WriteLine("Hello, World!");
      }
  }
  </code></pre>
  
  <p><strong>Helloworld.csproj</strong></p>
  
  <pre><code>&lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
      &lt;ItemGroup&gt;
          &lt;Compile Include="Helloworld.cs" /&gt;
      &lt;/ItemGroup&gt;
      &lt;Target Name="Build"&gt;
          &lt;Csc Sources="@(Compile)"/&gt;
      &lt;/Target&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>I very slowly pieced together a YAML file following <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops" rel="nofollow noreferrer">this Microsoft KB (<strong>"Build, test, and deploy .NET Core apps"</strong>)</a> and <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&amp;tabs=schema#task" rel="nofollow noreferrer">this one (<strong>"YAML Schema Reference"</strong>)</a>.</p>
  
  <p>When I tried to run the pipeline, the compiler for some reason seems to have a problem with the <code>System</code> namespace declaration in <code>Helloworld.cs</code> (which seems odd).</p>
  
  <p><strong>Pipeline Output</strong></p>
  
  <pre><code>Helloworld.cs(1,7): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?) [d:\a\1\s\Helloworld.csproj]
  Helloworld.cs(3,7): error CS0518: Predefined type 'System.Object' is not defined or imported [d:\a\1\s\Helloworld.csproj]
  Helloworld.cs(5,9): error CS0518: Predefined type 'System.Void' is not defined or imported [d:\a\1\s\Helloworld.csproj]
  
  Build FAILED.
  </code></pre>
  
  <p>So in my efforts to troubleshoot, I found this SO question:</p>
  
  <p><a href="https://stackoverflow.com/questions/33256896/the-type-or-namespace-name-system-could-not-be-found">The type or namespace name &#39;System&#39; could not be found</a></p>
  
  <p>Some answers suggested restoring <strong>NuGet</strong> packages. So I followed <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/nuget?view=azure-devops" rel="nofollow noreferrer">Microsoft's <strong>NuGet [pipeline] task</strong> documentation</a> to add a NuGet restore as the first stage in my YAML.</p>
  
  <p><strong>YAML File</strong></p>
  
  <pre><code>trigger:
  - master
  
  pool:
    vmImage: 'windows-latest'
  
  stages:
  - stage: Restore_NuGet_Stage
    displayName: 'Restore NuGet Stage'
    jobs:
    - job: restore_nuget
      displayName: 'Restore NuGet'
      steps:
      - task: NuGetCommand@2
        inputs:
          command: restore
  - stage: Build_Stage
    displayName: 'Build Stage'
    jobs: 
    - job: compile_cs
      displayName: 'Compile CS Files'
      steps:
      - task: DotNetCoreCLI@2
        displayName: 'Build Task'
        inputs:
          command: build
          projects: 'Helloworld.csproj'
          arguments: '--configuration Testing'
  </code></pre>
  
  <p>But I still get the exact same <code>namespace name 'System' could not be found</code> errors found above.</p>
  
  <p>What must I fix to get past this error? I thought just compiling the code was going to be the easy part...</p>
  
  <p><strong>EDIT</strong> - Here's the preliminary output shown when I run the pipeline. There's <code>.Net Core version 2.158.1</code> listed &amp; <code>SDK Version 3.0.100</code>, in case that helps</p>
  
  <pre><code>Starting: Build Task
  ==============================================================================
  Task         : .NET Core
  Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
  Version      : 2.158.1
  Author       : Microsoft Corporation
  Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
  ==============================================================================
  C:\windows\system32\chcp.com 65001
  Active code page: 65001
  "C:\Program Files\dotnet\dotnet.exe" build d:\a\1\s\Helloworld.csproj --configuration Testing
  
  Welcome to .NET Core 3.0!
  ---------------------
  SDK Version: 3.0.100
  </code></pre>