Skip to content

Commit

Permalink
Merge pull request #4369 from NREL/nuget_test
Browse files Browse the repository at this point in the history
#4214 Add in automated testing for 32/64 bit nuget package
  • Loading branch information
tijcolem authored Jul 23, 2021
2 parents a60c462 + 031dec2 commit 9198b9e
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
6 changes: 6 additions & 0 deletions csharp/nuget_test/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
29 changes: 29 additions & 0 deletions csharp/nuget_test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Simple command line steps to test the openstudio.nupkg package with a simple C# program.

1 ) Install nuget.exe
https://www.nuget.org/downloads

2 ) Install the nupkg using nuget cli
e.g.
nuget.exe add C:\Users\OpenStudio.3.2.0.nupkg -Source C:\Users\Administrator\source\
# verify package is installed
nuget.exe list -Prerelease -Source C:\Users\Administrator\source\

3 ) cd into directory where you want to install the nuget package and install
nuget.exe install OpenStudio -Version 3.2.0 -Source C:\Users\Administrator\source\

4 ) compile c# program using nuget package
csc /t:exe /out:test.exe /r:OpenStudio.3.2.0\lib\net35\OpenStudio.dll test_nuget.cs

5 ) copy all runtime dlls within the nuget package to directory or add it path that contains the compiled exe, in this case test.exe

6 ) run exec and test output


The nuget_setup.bat runs all the above for x64 and x86. You need to set the following before calling the script.
e.g.
set NUGET_PATH=D:\OSN\build&& set NUGET_NAME=OpenStudio&& set NUGET_VERSION=3.2.2-alpha&& set NUGET_SOURCE_DIR=D:\jenkins\nuget_packages&& test_nuget.bat




65 changes: 65 additions & 0 deletions csharp/nuget_test/test_nuget.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
REM Setup the Visual Studio env
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"

echo Testing %NUGET_NAME%.%NUGET_VERSION% with example csharp programs for x86 and x64 builds

SET ORIG_PATH=%PATH%


echo Adding nuget package to local source
echo nuget add %NUGET_PATH%\%NUGET_NAME%.%NUGET_VERSION%.nupkg -Source %NUGET_SOURCE_DIR%
nuget add %NUGET_PATH%\%NUGET_NAME%.%NUGET_VERSION%.nupkg -Source %NUGET_SOURCE_DIR%


echo List available nuget packages from local source
echo nuget list -Prerelease -Source %NUGET_SOURCE_DIR%
nuget list -Prerelease -Source %NUGET_SOURCE_DIR%

echo Install nuget packages from local source
nuget install %NUGET_NAME% -Version %NUGET_VERSION% -Source %NUGET_SOURCE_DIR%

REM create the dirs to write the compiled output
mkdir x64
mkdir x86

echo Compiling x64 and x86 csharp programs using %NUGET_NAME%.%NUGET_VERSION%.nupkg
REM compile x64 csharp example file
echo csc /t:exe /platform:x64 /out:x64\test.exe /r:%NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll test_nuget.cs
csc /t:exe /platform:x64 /out:x64\test.exe /r:%NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll test_nuget.cs

REM compile x86 csharp example file
echo csc /t:exe /platform:x86 /out:x86\test.exe /r:%NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll test_nuget.cs
csc /t:exe /platform:x86 /out:x86\test.exe /r:%NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll test_nuget.cs

REM get the test directory
SET BASE_DIR_NAME=%~d0%~p0

REM add x64 dlls to path
REM echo set PATH=%BASE_DIR_NAME%%NUGET_NAME%.%NUGET_VERSION%\build\x64;%PATH%
set PATH=%BASE_DIR_NAME%%NUGET_NAME%.%NUGET_VERSION%\build\x64;%PATH%
REM Copy the dll so test.exe for runtime dependency
echo copy %NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll x64
copy %NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll x64
REM run the test.exe
echo "test running x64\test.exe"
echo x64\test.exe
x64\test.exe

echo "test running x86\test.exe"
REM add x86 dlls to path
set PATH=%ORIG_PATH%
REM add x86 dlls to path
REM echo set PATH=%BASE_DIR_NAME%%NUGET_NAME%.%NUGET_VERSION%\build\x86;%PATH%
set PATH=%BASE_DIR_NAME%%NUGET_NAME%.%NUGET_VERSION%\build\x86;%PATH%
REM Copy the dll so test.exe for runtime dependency
echo copy %NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll x86
copy %NUGET_NAME%.%NUGET_VERSION%\lib\net35\OpenStudio.dll x86
REM run the test.exe
echo "test running x64\test.exe"
echo x86\test.exe
x86\test.exe


echo Deleting nuget package to local source
echo nuget delete %NUGET_NAME% %NUGET_VERSION% -Source %NUGET_SOURCE_DIR% -NonInteractive
nuget delete %NUGET_NAME% %NUGET_VERSION% -Source %NUGET_SOURCE_DIR% -NonInteractive
16 changes: 16 additions & 0 deletions csharp/nuget_test/test_nuget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test_nuget
{
class Program
{
static void Main(string[] args)
{
var m = new OpenStudio.Model();
}
}
}

0 comments on commit 9198b9e

Please # to comment.