Skip to content

Commit

Permalink
.Net: Fix build batch to align with Bash script (microsoft#2813)
Browse files Browse the repository at this point in the history
### Motivation and Context

**Why is this change required? What problem does it solve?** Consistent
developer experience across platforms.

**What scenario does it contribute to?** Developing the .NET solution on
Windows.

### Description

Steps to reproduce (assuming a Windows host and `main` being at
f159a0d, which was the case at the time
of opening this PR):

    git clone https://github.com/microsoft/semantic-kernel.git
    cd semantic-kernel
    git checkout f159a0d
    .\dotnet\build.cmd

Expected the build to succeed, but instead the output is:

    MSBuild version 17.7.3+8ec440e68 for .NET
MSBUILD : error MSB1003: Specify a project or solution file. The current
working directory does not contain a project or solution file.
MSBUILD : error MSB1003: Specify a project or solution file. The current
working directory does not contain a project or solution file.

The PR fixes the problem by updating `build.cmd` to be consistent with
`build.sh` in two ways:

- The script changes the current directory to the .NET solution root
- Tests are run via `build test` if the solution builds successfully via
`dotnet build`. This is done via `&&`.

The PR also updates `.gitattributes` to make sure that `*.cmd` files use
the `CRLF`, as is conventional for EOL on Windows.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

### Other Information

`dotnet --info` says:

    .NET SDK:
     Version:   7.0.401
     Commit:    eb26aacfec
    
    Runtime Environment:
     OS Name:     Windows
     OS Version:  10.0.22621
     OS Platform: Windows
     RID:         win10-x64
     Base Path:   C:\Program Files\dotnet\sdk\7.0.401\
    
    Host:
      Version:      7.0.11
      Architecture: x64
      Commit:       ecb34f85ec
    
    .NET SDKs installed:
      3.1.426 [C:\Program Files\dotnet\sdk]
      5.0.416 [C:\Program Files\dotnet\sdk]
      6.0.414 [C:\Program Files\dotnet\sdk]
      7.0.203 [C:\Program Files\dotnet\sdk]
      7.0.401 [C:\Program Files\dotnet\sdk]
    
    .NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.22 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.5 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.11 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program
Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program
Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.22 [C:\Program
Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.5 [C:\Program
Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.11 [C:\Program
Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program
Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program
Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.22 [C:\Program
Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.5 [C:\Program
Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.11 [C:\Program
Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    
    Other architectures found:
      x86   [C:\Program Files (x86)\dotnet]
registered at
[HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
    
    Environment variables:
      Not set
    
    global.json file:
      Not found
    
    Learn more:
      https://aka.ms/dotnet/info
    
    Download .NET:
      https://aka.ms/dotnet/download

Co-authored-by: Shawn Callegari <[email protected]>
  • Loading branch information
atifaziz and shawncal authored Sep 15, 2023
1 parent b87f44e commit ff45d4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
* text=auto eol=lf working-tree-encoding=UTF-8

# Bash scripts
*.sh text eol=lf
*.sh text eol=lf
*.cmd text eol=crlf
8 changes: 4 additions & 4 deletions dotnet/build.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off

dotnet build --configuration Release --interactive

dotnet test --configuration Release --no-build --no-restore --interactive
setlocal
cd "%~dp0"
dotnet build --configuration Release --interactive ^
&& dotnet test --configuration Release --no-build --no-restore --interactive

0 comments on commit ff45d4b

Please sign in to comment.