Upgrade source code, project files and scripts to use .NET Core. Mono is not required anymore, and also the Docker image will now use only .NET Core.
The configuration format has changed to be in line with ASP.NET Core configuration providers.
The simulation runner is temporarily disabled, because Akka.NET is not ready for .NET Core, and I'm in the middle of removing Akka from the project as well.
Due to the move from .NET Core, some internal APIs are different, for instance you might notice changes in the web service exception filter, in the Autofac dependency injection setup, in the use of Kestrel as a HTTP server.
Since the microservice is now built and packaged with the `dotnet` command, some paths have changed, and scripts have been updated accordingly. I tested the scripts in Windows and MacOS, hopefully catching all the edge cases. The scripts are now actually simpler, which is a nice and unexpected result of the migration.
This commit is contained in:
Devis Lucato 2017-06-20 18:52:50 -07:00 коммит произвёл GitHub
Родитель 2302587b1b
Коммит 8a4e79cf00
65 изменённых файлов: 630 добавлений и 1546 удалений

Просмотреть файл

@ -1,6 +1,5 @@
language: csharp
mono: beta
dotnet: 1.0.1
dotnet: 1.0.3
dist: trusty
sudo: false
cache:
@ -8,6 +7,10 @@ cache:
- "$HOME/.nuget/"
before_install:
- set -e
addons:
apt:
packages:
- dotnet-sharedframework-microsoft.netcore.app-1.1.2
script:
- "bash ./$CODEBASE/scripts/build"
notifications:

Просмотреть файл

@ -20,9 +20,9 @@ The [scripts](scripts) folder includes some scripts for frequent tasks:
### Sandbox
Most of the scripts assume you have configured your development environment,
with tools like MSBuild, Nuget, .NET Core, Mono and Docker. You can avoid
installing all of these tools, and install only Docker, and use the scripts
with `-in-sandbox` suffix:
with tools like .NET Core and Docker. You can avoid installing .NET Core,
and install only Docker, and use the scripts with `-in-sandbox` suffix,
for example:
* `build-in-sandbox`: like `build` but executes the task inside of a Docker
container.
@ -70,18 +70,11 @@ Development setup
## .NET setup
The project workflow is managed via .NET Framework 4.6.2+ and Mono 5.x.
We recommend to install Mono also in Windows, where Mono is used for the
Git pre-commit hook.
The project workflow is managed via .NET Core 1.0.4.
We recommend to install .NET Core in your environment, so that you can
run all the scripts and ensure that your IDE works as expected.
On the other hand you can install just Docker and rely on the builder
sandbox if you don't want to install all these dependencies.
Some scripts also require .NET Core, where we are migrating the solution.
* [.NET for Windows](https://support.microsoft.com/help/3151802/the-.net-framework-4.6.2-web-installer-for-windows)
* [Mono 5](http://www.mono-project.com/download)
* [.NET Core](https://dotnet.github.io/)
* [.NET Core](https://dotnet.github.io)
We provide also a
[Java version](https://github.com/Azure/device-simulation-java)
@ -93,8 +86,8 @@ Here are some IDE that you can use to work on Azure IoT PCS:
* [Visual Studio](https://www.visualstudio.com/)
* [IntelliJ Rider](https://www.jetbrains.com/rider)
* [Visual Studio Code](https://code.visualstudio.com/)
* [Visual Studio for Mac](https://www.visualstudio.com/vs/visual-studio-mac)
* [Visual Studio Code](https://code.visualstudio.com/)
## Git setup
@ -119,8 +112,8 @@ setup --with-sandbox
#### Pre-commit hook without sandbox
Note: the hook requires [Mono 5](http://www.mono-project.com/download),
Nuget and MSBuild in the system PATH.
Note: the hook without sandbox requires [.NET Core](https://dotnet.github.io)
in the system PATH.
To setup the included hooks, open a Windows/Linux/MacOS console and execute:
@ -130,6 +123,14 @@ cd scripts/git
setup --no-sandbox
```
To setup the precommit hook using the Docker sandbox instead:
```
cd PROJECT-FOLDER
cd scripts/git
setup --with-sandbox
```
## Code style
If you use ReSharper or Rider, you can load the code style settings from

Просмотреть файл

@ -1,12 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Services.Test")]
[assembly: AssemblyProduct("Services.Test")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("CDB4D7B6-84D6-48F8-983F-81843B288699")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

106
Services.Test/Services.Test.csproj Executable file → Normal file
Просмотреть файл

@ -1,101 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1BC54189-1DF9-448E-AE5F-66EB2EF51D82}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Services.Test</RootNamespace>
<AssemblyName>Services.Test</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>6</LangVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc">
<HintPath>..\packages\Castle.Core.4.0.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.7.25.0, Culture=neutral, PublicKeyToken=69f491c39445e920">
<HintPath>..\packages\Moq.4.7.25\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="Moq.InvocationOrder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Moq.InvocationOrder.2.0.0\lib\net462\Moq.InvocationOrder.dll</HintPath>
</Reference>
<Reference Include="MoqExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\MoqExtensions.0.0.2\lib\net45\MoqExtensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.2" />
<PackageReference Include="Moq" Version="4.7.49" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.assert" Version="2.2.0" />
<PackageReference Include="xunit.runner.console" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="helpers\Constants.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimulationsTest.cs" />
<ProjectReference Include="..\Services\Services.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Services\Services.csproj">
<Project>{8acbc846-b16c-4857-94f1-0bb297fe1cd3}</Project>
<Name>Services</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Content Include="IntegrationTests\README.md" />
<Content Include="README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
</Project>
</Project>

Просмотреть файл

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.0.0" targetFramework="net462" />
<package id="Moq" version="4.7.25" targetFramework="net462" />
<package id="Moq.InvocationOrder" version="2.0.0" targetFramework="net462" />
<package id="MoqExtensions" version="0.0.2" targetFramework="net462" />
<package id="xunit" version="2.2.0" targetFramework="net462" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
<package id="xunit.runner.console" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
</packages>

Просмотреть файл

@ -1,12 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Microsoft.Azure.IoTSolutions.DeviceSimulation.Services")]
[assembly: AssemblyProduct("Microsoft.Azure.IoTSolutions.DeviceSimulation.Services")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("8ACBC846-B16C-4857-94F1-0BB297FE1CD3")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

90
Services/Services.csproj Executable file → Normal file
Просмотреть файл

@ -1,87 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{786A5B9B-98EE-4B73-9FE3-2080B70007AF}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Azure.IoTSolutions.DeviceSimulation.Services</RootNamespace>
<TargetFramework>netstandard1.6</TargetFramework>
<LangVersion>6</LangVersion>
<AssemblyName>Microsoft.Azure.IoTSolutions.DeviceSimulation.Services</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>anycpu</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>Default</LangVersion>
<RootNamespace>Microsoft.Azure.IoTSolutions.DeviceSimulation.Services</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<PackageReference Include="Microsoft.Azure.Devices.Client" Version="1.2.13" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
<ItemGroup>
<Compile Include="Concurrency\Etags.cs" />
<Compile Include="Exceptions\ConflictingResourceException.cs" />
<Compile Include="Exceptions\InvalidInputException.cs" />
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
<Compile Include="Exceptions\ResourceOutOfDateException.cs" />
<Compile Include="Models\SimulationPatch.cs" />
<Compile Include="Simulations.cs" />
<Compile Include="DeviceTypes.cs" />
<Compile Include="Exceptions\InvalidConfigurationException.cs" />
<Compile Include="Models\DeviceType.cs" />
<Compile Include="Models\IoTHubProtocol.cs" />
<Compile Include="Models\Simulation.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Runtime\ServicesConfig.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="data\DeviceTypes\chiller.json">
<None Update="data\DeviceTypes\chiller.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="data\DeviceTypes\elevator.json">
</None>
<None Update="data\DeviceTypes\elevator.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="data\DeviceTypes\README.md" />
<Content Include="data\DeviceTypes\truck.json">
</None>
<None Update="data\DeviceTypes\truck.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Models\README.md" />
<Content Include="packages.config" />
<Content Include="README.md" />
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="data" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>

Просмотреть файл

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net462" />
</packages>

Просмотреть файл

@ -1,12 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("SimulationAgent.Test")]
[assembly: AssemblyProduct("SimulationAgent.Test")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("EF2B3E7D-4FFA-4B63-9E36-BDE17273D38B")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,88 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{EF2B3E7D-4FFA-4B63-9E36-BDE17273D38B}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SimulationAgent.Test</RootNamespace>
<AssemblyName>SimulationAgent.Test</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>6</LangVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc">
<HintPath>..\packages\Castle.Core.4.0.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.7.25.0, Culture=neutral, PublicKeyToken=69f491c39445e920">
<HintPath>..\packages\Moq.4.7.25\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="Moq.InvocationOrder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Moq.InvocationOrder.2.0.0\lib\net462\Moq.InvocationOrder.dll</HintPath>
</Reference>
<Reference Include="MoqExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\MoqExtensions.0.0.2\lib\net45\MoqExtensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.2" />
<PackageReference Include="Moq" Version="4.7.49" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.assert" Version="2.2.0" />
<PackageReference Include="xunit.runner.console" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<ProjectReference Include="..\SimulationAgent\SimulationAgent.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SimulationAgent\SimulationAgent.csproj">
<Project>{3739a325-246d-48c7-a59f-a355bea0e6df}</Project>
<Name>SimulationAgent</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
</Project>
</Project>

Просмотреть файл

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.0.0" targetFramework="net462" />
<package id="Moq" version="4.7.25" targetFramework="net462" />
<package id="Moq.InvocationOrder" version="2.0.0" targetFramework="net462" />
<package id="MoqExtensions" version="0.0.2" targetFramework="net462" />
<package id="xunit" version="2.2.0" targetFramework="net462" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
<package id="xunit.runner.console" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
</packages>

Просмотреть файл

@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using Akka.Actor;
using Autofac;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime;
@ -11,11 +10,56 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent
{
public static class DependencyResolution
{
/// <summary>
/// Autofac configuration. Find more information here:
/// @see http://docs.autofac.org/en/latest/integration/aspnetcore.html
/// </summary>
public static IContainer Setup()
{
var builder = new ContainerBuilder();
AutowireAssemblies(builder);
SetupCustomRules(builder);
var container = builder.Build();
RegisterFactory(container);
return container;
}
/// <summary>Autowire interfaces to classes from all the assemblies</summary>
private static void AutowireAssemblies(ContainerBuilder builder)
{
var assembly = Assembly.GetEntryAssembly();
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
}
/// <summary>Setup Custom rules overriding autowired ones.</summary>
private static void SetupCustomRules(ContainerBuilder builder)
{
// Make sure the configuration is read only once.
var config = new Config(new ConfigData());
builder.RegisterInstance(config).As<IConfig>().SingleInstance();
// Service configuration is generated by the entry point, so we
// prepare the instance here.
builder.RegisterInstance(config.ServicesConfig).As<IServicesConfig>().SingleInstance();
// Reusable instances (singletons)
builder.RegisterType<Simulations>().As<ISimulations>().SingleInstance();
builder.RegisterType<DeviceTypes>().As<IDeviceTypes>().SingleInstance();
}
private static void RegisterFactory(IContainer container)
{
Factory.RegisterContainer(container);
}
/// <summary>
/// Provide factory pattern for dependencies that are instantiated
/// multiple times during the application lifetime.
/// How to use:
///
/// <code>
/// class MyClass : IMyClass {
/// public MyClass(DependencyInjection.IFactory factory) {
/// this.factory = factory;
@ -26,6 +70,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent
/// var instance3 = this.factory.Resolve<ISomething>();
/// }
/// }
/// </code>
/// </summary>
public interface IFactory
{
@ -46,60 +91,5 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent
return container.Resolve<T>();
}
}
/// <summary>
/// Autofac configuration. Find more information here:
/// http://docs.autofac.org/en/latest/integration/owin.html
/// http://autofac.readthedocs.io/en/latest/register/scanning.html
/// </summary>
public static IContainer Setup()
{
var builder = new ContainerBuilder();
AutowireAssemblies(builder);
SetupCustomRules(builder);
var container = builder.Build();
Factory.RegisterContainer(container);
return container;
}
/// <summary>
/// Autowire interfaces to classes. Note that the solution assemblies
/// are explicitly managed here. This could be extended to analyze
/// all the assemblies directly and indirectly referenced.
/// </summary>
private static void AutowireAssemblies(ContainerBuilder builder)
{
var assembly = Assembly.GetExecutingAssembly();
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
assembly = typeof(ServicesConfig).Assembly;
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
}
/// <summary>Setup Custom rules overriding autowired ones.</summary>
private static void SetupCustomRules(ContainerBuilder builder)
{
// Make sure the configuration is read only once.
var config = new Config(new ConfigData());
builder.RegisterInstance(config).As<IConfig>().SingleInstance();
// Service configuration is generated by the entry point, so we
// prepare the instance here.
builder.RegisterInstance(config.ServicesConfig).As<IServicesConfig>().SingleInstance();
// Reusable instances (singletons)
builder.RegisterType<Simulations>().As<ISimulations>().SingleInstance();
builder.RegisterType<DeviceTypes>().As<IDeviceTypes>().SingleInstance();
// ActorSystem is a heavy object: create only one per application.
// @see http://getakka.net/docs/working-with-actors/creating-actors
IActorRefFactory actorSystem = ActorSystem.Create(
"Microsoft.Azure.IoTSolutions.DeviceSimulation".Replace(".", ""));
builder.RegisterInstance(actorSystem).As<IActorRefFactory>().SingleInstance();
}
}
}

Просмотреть файл

@ -1,9 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using Autofac;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Runtime;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Simulation;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent
{
@ -16,7 +14,13 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent
Console.WriteLine($"[{Uptime.ProcessId}] Press [CTRL+C] to quit...");
var container = DependencyResolution.Setup();
container.Resolve<ISimulation>().Run();
// TODO: re-enable after migration to .NET Core
//container.Resolve<Simulation.ISimulation>().Run();
while (true)
{
Console.ReadLine();
}
}
}
}

Просмотреть файл

@ -1,12 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent")]
[assembly: AssemblyProduct("Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("3739A325-246D-48C7-A59F-A355BEA0E6DF")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,10 +1,12 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.IO;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime;
// TODO: tests
// TODO: handle errors
// TODO: use JSON?
// TODO: use binding
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Runtime
{
public interface IConfig
@ -16,7 +18,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Runtime
/// <summary>Web service configuration</summary>
public class Config : IConfig
{
private const string Application = "device-simulation.";
private const string Application = "devicesimulation:";
/// <summary>Service layer configuration</summary>
public IServicesConfig ServicesConfig { get; }
@ -25,11 +27,17 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Runtime
{
this.ServicesConfig = new ServicesConfig
{
DeviceTypesFolder = configData.GetString(Application + "device-types-folder"),
DeviceTypesBehaviorFolder = configData.GetString(Application + "device-types-behavior-folder"),
IoTHubManagerApiHost = configData.GetString("iothubmanager.webservice.host"),
IoTHubManagerApiPort = configData.GetInt("iothubmanager.webservice.port")
DeviceTypesFolder = MapRelativePath(configData.GetString(Application + "device_types_folder")),
DeviceTypesBehaviorFolder = MapRelativePath(configData.GetString(Application + "device_types_behavior_folder")),
IoTHubManagerApiHost = configData.GetString("iothubmanager:webservice_host"),
IoTHubManagerApiPort = configData.GetInt("iothubmanager:webservice_port")
};
}
private static string MapRelativePath(string path)
{
if (path.StartsWith(".")) return AppContext.BaseDirectory + Path.DirectorySeparatorChar + path;
return path;
}
}
}

Просмотреть файл

@ -2,9 +2,9 @@
using System;
using System.Collections;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Extensions.Configuration;
// TODO: tests
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Runtime
@ -17,9 +17,22 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Runtime
public class ConfigData : IConfigData
{
private readonly IConfigurationRoot configuration;
public ConfigData()
{
// More info about configuration at
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddIniFile("appsettings.ini", optional: true, reloadOnChange: true);
this.configuration = configurationBuilder.Build();
}
public string GetString(string key)
{
var value = ConfigurationManager.AppSettings[key];
var value = this.configuration.GetValue<string>(key);
return ReplaceEnvironmentVariables(value);
}

Просмотреть файл

@ -1,50 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Linq;
using System.Threading;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Simulation
{
public interface ISimulation
{
void Run();
}
public class Simulation : ISimulation
{
private const int CheckInterval = 3000;
private readonly ISimulations simulations;
private readonly ISimulationRunner runner;
public Simulation(
ISimulations simulations,
ISimulationRunner runner)
{
this.simulations = simulations;
this.runner = runner;
}
public void Run()
{
Console.WriteLine("Simulation Agent running");
while (true)
{
var simulation = this.simulations.GetList().FirstOrDefault();
if (simulation != null && simulation.Enabled)
{
this.runner.Start(simulation);
}
else
{
this.runner.Stop();
}
Thread.Sleep(CheckInterval);
}
}
}
}

Просмотреть файл

@ -1,70 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using Akka.Actor;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Models;
// TODO: add DI - @see http://getakka.net/docs/Dependency%20injection
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Simulation
{
public class DeviceActor : ReceiveActor
{
private int position;
private DeviceType deviceType;
private IoTHubProtocol protocol;
private bool isRunning;
private List<ICancelable> tasks;
public DeviceActor()
{
this.tasks = new List<ICancelable>();
this.Receive<DeviceActorMessages.Setup>(msg => this.DoSetup(msg.Position, msg.DeviceType));
this.Receive<DeviceActorMessages.Start>(msg => this.DoStart());
this.Receive<DeviceActorMessages.Stop>(msg => this.DoStop());
this.Receive<DeviceActorMessages.SendTelemetry>(msg => this.DoSendTelemetry(msg.Message));
}
private void DoSetup(int position, DeviceType deviceType)
{
this.isRunning = false;
this.position = position;
this.deviceType = deviceType;
this.protocol = deviceType.Protocol;
Console.WriteLine($"Starting device type {this.deviceType.Name}");
}
private void DoStart()
{
if (this.isRunning) return;
this.isRunning = true;
// Schedule telemetry sender
foreach (var message in this.deviceType.Telemetry.Messages)
{
var telemetryMsg = new DeviceActorMessages.SendTelemetry(message);
var task = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(
TimeSpan.Zero, message.Interval, this.Self, telemetryMsg, this.Self);
this.tasks.Add(task);
}
}
private void DoStop()
{
if (!this.isRunning) return;
foreach (var task in this.tasks)
{
task.Cancel();
}
this.isRunning = false;
}
private void DoSendTelemetry(DeviceType.DeviceTypeMessage message)
{
Console.WriteLine("Sending telemetry: " + message.Message);
}
}
}

Просмотреть файл

@ -1,42 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Models;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Simulation
{
/// <summary>
/// A collection of message types that can be sent to a DeviceActor.
/// </summary>
public class DeviceActorMessages
{
public class Setup
{
public DeviceType DeviceType { get; }
public int Position { get; }
public Setup(int position, DeviceType deviceType)
{
this.Position = position;
this.DeviceType = deviceType;
}
}
public class Start
{
}
public class Stop
{
}
public class SendTelemetry
{
public DeviceType.DeviceTypeMessage Message { get; }
public SendTelemetry(DeviceType.DeviceTypeMessage message)
{
this.Message = message;
}
}
}
}

Просмотреть файл

@ -1,95 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using Akka.Actor;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Models;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.Simulation
{
public interface ISimulationRunner
{
void Start(Services.Models.Simulation simulation);
void Stop();
}
public class SimulationRunner : ISimulationRunner
{
private readonly IDeviceTypes deviceTypes;
private readonly IActorRefFactory actorSystem;
private readonly List<bool> running;
private List<IActorRef> actors;
public SimulationRunner(
IDeviceTypes deviceTypes,
IActorRefFactory actorSystem)
{
this.deviceTypes = deviceTypes;
this.actorSystem = actorSystem;
this.running = new List<bool> { false };
this.actors = new List<IActorRef>();
}
/// <summary>
/// For each device type create a set of indipendent actors.
/// Each actor takes care of simulating a device.
/// </summary>
public void Start(Services.Models.Simulation simulation)
{
lock (this.running)
{
// Nothing to do if already running
if (this.running.FirstOrDefault()) return;
Console.WriteLine($"Starting simulation {simulation.Id}...");
this.running[0] = true;
foreach (var dt in simulation.DeviceTypes)
{
DeviceType deviceType = this.deviceTypes.Get(dt.Id);
for (int i = 0; i < dt.Count; i++)
{
var actor = this.actorSystem.ActorOf<DeviceActor>();
this.actors.Add(actor);
actor.Tell(new DeviceActorMessages.Setup(i, deviceType));
actor.Tell(new DeviceActorMessages.Start());
}
}
}
}
/// <summary>
/// Send a message to all the actors asking to stop running
/// </summary>
public void Stop()
{
lock (this.running)
{
// Nothing to do if not running
if (!this.running.FirstOrDefault()) return;
Console.WriteLine("Stopping simulation...");
// TODO: use Akka pubsub
/* This approach to stop the actors works fine and keeps
the logs clean, however it doesnt scale when there are
thousands/millions of actors. TO DO: (1) organize the actors
under few master nodes, (2) use pubsub to tell the cluster to
stop, and (3) kill the master nodes after few seconds. */
foreach (var actor in this.actors)
{
actor.Tell(new DeviceActorMessages.Stop());
actor.GracefulStop(TimeSpan.FromSeconds(10));
}
this.actors = new List<IActorRef>();
this.running[0] = false;
}
}
}
}

Просмотреть файл

@ -1,78 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3739A325-246D-48C7-A59F-A355BEA0E6DF}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent</RootNamespace>
<AssemblyName>Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFramework>netcoreapp1.1</TargetFramework>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AssemblyName>Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent</AssemblyName>
<RootNamespace>Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Reference Include="Akka, Version=1.2.0.33, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Akka.1.2.0\lib\net45\Akka.dll</HintPath>
</Reference>
<Reference Include="Autofac, Version=4.6.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da">
<HintPath>..\packages\Autofac.4.6.0\lib\net45\Autofac.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<HintPath>..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Runtime\ConfigData.cs" />
<Compile Include="Simulation\DeviceActor.cs" />
<Compile Include="Simulation\DeviceActorMessages.cs" />
<Compile Include="Simulation\SimulationRunner.cs" />
<Compile Include="Simulation\Agent.cs" />
<Compile Include="DependencyResolution.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Runtime\Config.cs" />
<Compile Include="Runtime\Uptime.cs" />
<PackageReference Include="Autofac" Version="4.6.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="1.1.2" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Services\Services.csproj">
<Project>{786a5b9b-98ee-4b73-9fe3-2080b70007af}</Project>
<Name>Services</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<Content Include="appsettings.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>

Просмотреть файл

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
</configSections>
<appSettings>
<add key="device-simulation.device-types-folder" value="./data/DeviceTypes/" />
<add key="device-simulation.device-types-behavior-folder" value="./data/scripts/" />
<add key="iothubmanager.webservice.host" value="${PCS_IOTHUBMANAGER_WEBSERVICE_HOST}"/>
<add key="iothubmanager.webservice.port" value="${PCS_IOTHUBMANAGER_WEBSERVICE_PORT}"/>
</appSettings>
<akka>
<hocon>
<![CDATA[
# NOTE: this configuration block is in HOCON format [1][2].
# [1] http://getakka.net/docs/concepts/hocon
# [2] https://en.wikipedia.org/wiki/HOCON
# By convention property names are lowercase.
# By convention env. variable name are uppercase.
akka {
# Options: OFF, ERROR, WARNING, INFO, DEBUG
loglevel: INFO
# Suppresses warning about usage of the default (JSON.NET) serializer
# which is going to be obsoleted at v1.5
# http://getakka.net/docs/Serialization#how-to-setup-hyperion-as-default-serializer
suppress-json-serializer-warning: on
}
]]>
</hocon>
</akka>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -0,0 +1,8 @@
[devicesimulation]
device_types_folder = ./data/DeviceTypes/
device_types_behavior_folder = ./data/scripts/
[iothubmanager]
webservice_host = ${PCS_IOTHUBMANAGER_WEBSERVICE_HOST}
webservice_port = ${PCS_IOTHUBMANAGER_WEBSERVICE_PORT}
webservice_timeout = 10

Просмотреть файл

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Akka" version="1.2.0" targetFramework="net462" />
<package id="Autofac" version="4.6.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net462" />
<package id="System.Collections.Immutable" version="1.3.1" targetFramework="net462" />
</packages>

Просмотреть файл

@ -1,12 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("WebService.Test")]
[assembly: AssemblyProduct("WebService.Test")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("15CBDB1E-2AA0-438B-B502-A6483AB594B4")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

97
WebService.Test/WebService.Test.csproj Executable file → Normal file
Просмотреть файл

@ -1,97 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6A4D86AD-56D0-421B-B9B2-2EBB34A5BBBC}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebService.Test</RootNamespace>
<AssemblyName>WebService.Test</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>6</LangVersion>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc">
<HintPath>..\packages\Castle.Core.4.0.0\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.7.25.0, Culture=neutral, PublicKeyToken=69f491c39445e920">
<HintPath>..\packages\Moq.4.7.25\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="Moq.InvocationOrder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\Moq.InvocationOrder.2.0.0\lib\net462\Moq.InvocationOrder.dll</HintPath>
</Reference>
<Reference Include="MoqExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\packages\MoqExtensions.0.0.2\lib\net45\MoqExtensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="helpers\Constants.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.2" />
<PackageReference Include="Moq" Version="4.7.49" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.assert" Version="2.2.0" />
<PackageReference Include="xunit.runner.console" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebService\WebService.csproj">
<Project>{2834a1fa-8d60-4ba4-9155-e318608b1c4f}</Project>
<Project>{7e275ae4-f7e1-49c7-9937-78615fdae192}</Project>
<Name>WebService</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<Content Include="README.md" />
<Content Include="IntegrationTests\README.md" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.2.0\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
</Project>

Просмотреть файл

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Castle.Core" version="4.0.0" targetFramework="net462" />
<package id="Moq" version="4.7.25" targetFramework="net462" />
<package id="Moq.InvocationOrder" version="2.0.0" targetFramework="net462" />
<package id="MoqExtensions" version="0.0.2" targetFramework="net462" />
<package id="xunit" version="2.2.0" targetFramework="net462" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net462" />
<package id="xunit.assert" version="2.2.0" targetFramework="net462" />
<package id="xunit.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net462" />
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net462" />
<package id="xunit.runner.console" version="2.2.0" targetFramework="net462" developmentDependency="true" />
<package id="xunit.runner.visualstudio" version="2.2.0" targetFramework="net462" developmentDependency="true" />
</packages>

Просмотреть файл

@ -1,107 +1,41 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using System.Web.Http;
using Autofac;
using Autofac.Integration.WebApi;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime;
using Owin;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService
{
public class DependencyResolution
{
//// <summary>
/// Provide factory pattern for dependencies that are instantiated
/// multiple times during the application lifetime.
/// How to use:
///
/// class MyClass : IMyClass {
/// public MyClass(DependencyInjection.IFactory factory) {
/// this.factory = factory;
/// }
/// public SomeMethod() {
/// var instance1 = this.factory.Resolve<ISomething>();
/// var instance2 = this.factory.Resolve<ISomething>();
/// var instance3 = this.factory.Resolve<ISomething>();
/// }
/// }
/// </summary>
public interface IFactory
{
T Resolve<T>();
}
public class Factory : IFactory
{
private static IContainer container;
public static void RegisterContainer(IContainer c)
{
container = c;
}
public T Resolve<T>()
{
return container.Resolve<T>();
}
}
/// <summary>
/// Autofac configuration. Find more information here:
/// http://docs.autofac.org/en/latest/integration/owin.html
/// http://autofac.readthedocs.io/en/latest/register/scanning.html
/// @see http://docs.autofac.org/en/latest/integration/aspnetcore.html
/// </summary>
public static IContainer Setup(IAppBuilder app, HttpConfiguration config)
public static IContainer Setup(IServiceCollection services)
{
var builder = new ContainerBuilder();
builder.Populate(services);
AutowireAssemblies(builder);
SetupCustomRules(builder);
SetupWebApiRules(builder);
var container = builder.Build();
Factory.RegisterContainer(container);
SetupWebApiResolution(app, config, container);
RegisterFactory(container);
return container;
}
/// <summary>
/// Autowire interfaces to classes. Note that the solution assemblies
/// are explicitly managed here. This could be extended to analyze
/// all the assemblies directly and indirectly referenced.
/// </summary>
/// <summary>Autowire interfaces to classes from all the assemblies</summary>
private static void AutowireAssemblies(ContainerBuilder builder)
{
var assembly = Assembly.GetExecutingAssembly();
var assembly = Assembly.GetEntryAssembly();
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
assembly = typeof(ServicesConfig).Assembly;
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
}
private static void SetupWebApiRules(ContainerBuilder builder)
{
// Register Web API controllers in executing assembly.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
}
private static void SetupWebApiResolution(IAppBuilder app, HttpConfiguration config, IContainer container)
{
// Create and assign a dependency resolver for Web API to use.
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
// The Autofac middleware should be the first middleware added to
// the IAppBuilder.
app.UseAutofacMiddleware(container);
// Make sure the Autofac lifetime scope is passed to Web API.
app.UseAutofacWebApi(config);
}
/// <summary>Setup Custom rules overriding autowired ones.</summary>
@ -122,5 +56,47 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService
builder.RegisterType<Simulations>().As<ISimulations>().SingleInstance();
builder.RegisterType<DeviceTypes>().As<IDeviceTypes>().SingleInstance();
}
private static void RegisterFactory(IContainer container)
{
Factory.RegisterContainer(container);
}
/// <summary>
/// Provide factory pattern for dependencies that are instantiated
/// multiple times during the application lifetime.
/// How to use:
/// <code>
/// class MyClass : IMyClass {
/// public MyClass(DependencyInjection.IFactory factory) {
/// this.factory = factory;
/// }
/// public SomeMethod() {
/// var instance1 = this.factory.Resolve<ISomething>();
/// var instance2 = this.factory.Resolve<ISomething>();
/// var instance3 = this.factory.Resolve<ISomething>();
/// }
/// }
/// </code>
/// </summary>
public interface IFactory
{
T Resolve<T>();
}
public class Factory : IFactory
{
private static IContainer container;
public static void RegisterContainer(IContainer c)
{
container = c;
}
public T Resolve<T>()
{
return container.Resolve<T>();
}
}
}
}

Просмотреть файл

@ -1,35 +1,28 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime;
using Microsoft.Owin.Hosting;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService
{
/// <summary>Application entry point</summary>
public class Program
{
static readonly IConfig config = new Config(new ConfigData());
static void Main(string[] args)
public static void Main(string[] args)
{
var options = new StartOptions("http://*:" + config.Port);
using (WebApp.Start<Startup>(options))
{
Console.WriteLine($"[{Uptime.ProcessId}] Web service started, process ID: " + Uptime.ProcessId);
Console.WriteLine($"[{Uptime.ProcessId}] Listening at http://*:" + config.Port);
Console.WriteLine($"[{Uptime.ProcessId}] Health check: http://127.0.0.1:" + config.Port + "/" + v1.Version.Path + "/status");
var config = new Config(new ConfigData());
// Production mode: keep the service alive until killed
if (args.Length > 0 && args[0] == "--background")
{
while (true) Console.ReadLine();
}
/*
Kestrel is a cross-platform HTTP server based on libuv, a cross-platform asynchronous I/O library.
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/
*/
var host = new WebHostBuilder()
.UseUrls("http://*:" + config.Port)
.UseKestrel(options => { options.AddServerHeader = false; })
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
// Development mode: keep the service alive until Enter is pressed
Console.WriteLine("Press [Enter] to quit...");
Console.ReadLine();
}
host.Run();
}
}
}

Просмотреть файл

@ -1,12 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService")]
[assembly: AssemblyProduct("Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService")]
[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("2834a1fa-8d60-4ba4-9155-e318608b1c4f")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,10 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.IO;
using System.Reflection;
using Microsoft.AspNetCore.Hosting.Internal;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Runtime;
// TODO: tests
// TODO: handle errors
// TODO: use JSON?
// TODO: use binding
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime
{
public interface IConfig
@ -19,7 +23,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime
/// <summary>Web service configuration</summary>
public class Config : IConfig
{
private const string Application = "device-simulation.";
private const string Application = "devicesimulation:";
/// <summary>Web service listening port</summary>
public int Port { get; }
@ -29,15 +33,21 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime
public Config(IConfigData configData)
{
this.Port = configData.GetInt(Application + "webservice.port");
this.Port = configData.GetInt(Application + "webservice_port");
this.ServicesConfig = new ServicesConfig
{
DeviceTypesFolder = configData.GetString(Application + "device-types-folder"),
DeviceTypesBehaviorFolder = configData.GetString(Application + "device-types-behavior-folder"),
IoTHubManagerApiHost = configData.GetString("iothubmanager.webservice.host"),
IoTHubManagerApiPort = configData.GetInt("iothubmanager.webservice.port")
DeviceTypesFolder = MapRelativePath(configData.GetString(Application + "device_types_folder")),
DeviceTypesBehaviorFolder = MapRelativePath(configData.GetString(Application + "device_types_behavior_folder")),
IoTHubManagerApiHost = configData.GetString("iothubmanager:webservice_host"),
IoTHubManagerApiPort = configData.GetInt("iothubmanager:webservice_port")
};
}
private static string MapRelativePath(string path)
{
if (path.StartsWith(".")) return AppContext.BaseDirectory + Path.DirectorySeparatorChar + path;
return path;
}
}
}

Просмотреть файл

@ -2,10 +2,10 @@
using System;
using System.Collections;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Exceptions;
using Microsoft.Extensions.Configuration;
// TODO: tests
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime
@ -18,9 +18,22 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.Runtime
public class ConfigData : IConfigData
{
private readonly IConfigurationRoot configuration;
public ConfigData()
{
// More info about configuration at
// https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddIniFile("appsettings.ini", optional: true, reloadOnChange: true);
this.configuration = configurationBuilder.Build();
}
public string GetString(string key)
{
var value = ConfigurationManager.AppSettings[key];
var value = this.configuration.GetValue<string>(key);
return ReplaceEnvironmentVariables(value);
}

Просмотреть файл

@ -1,39 +1,63 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Web.Http;
using Microsoft.Web.Http.Routing;
using Owin;
using System;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService
{
/// <summary>Application wrapper started by the entry point, see Program.cs</summary>
public class Startup
{
public void Configuration(IAppBuilder app)
// Initialized in `Startup`
public IConfigurationRoot Configuration { get; }
// Initialized in `ConfigureServices`
public IContainer ApplicationContainer { get; private set; }
// Invoked by `Program.cs`
public Startup(IHostingEnvironment env)
{
var config = new HttpConfiguration();
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddIniFile("appsettings.ini", optional: false, reloadOnChange: true);
this.Configuration = builder.Build();
}
DependencyResolution.Setup(app, config);
// This is where you register dependencies, add services to the
// container. This method is called by the runtime, before the
// Configure method below.
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Add controllers as services so they'll be resolved.
services.AddMvc().AddControllersAsServices();
config.AddApiVersioning(o =>
{
// When this property is set to `true`, the HTTP headers
// "api-supported-versions" and "api-deprecated-versions" will
// be added to all valid service routes. This information is
// useful for advertising which versions are supported and
// scheduled for deprecation to clients. This information is
// also useful when supporting the OPTIONS verb.
o.ReportApiVersions = true;
o.AssumeDefaultVersionWhenUnspecified = false;
});
this.ApplicationContainer = DependencyResolution.Setup(services);
config.Routes.MapHttpRoute(
name: "VersionedApi",
routeTemplate: "v{apiVersion}/{controller}/{id}",
defaults: new { id = RouteParameter.Optional },
constraints: new { apiVersion = new ApiVersionRouteConstraint() });
// Create the IServiceProvider based on the container
return new AutofacServiceProvider(this.ApplicationContainer);
}
app.UseWebApi(config);
// This method is called by the runtime, after the ConfigureServices
// method above. Use this method to add middleware.
public void Configure(
IApplicationBuilder app,
IHostingEnvironment env,
ILoggerFactory loggerFactory,
IApplicationLifetime appLifetime)
{
loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseMvc();
// If you want to dispose of resources that have been resolved in the
// application container, register for the "ApplicationStopped" event.
appLifetime.ApplicationStopped.Register(() => this.ApplicationContainer.Dispose());
}
}
}

129
WebService/WebService.csproj Executable file → Normal file
Просмотреть файл

@ -1,126 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F305CAD5-BE38-4391-A692-580C526A0CB1}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService</RootNamespace>
<TargetFramework>netcoreapp1.1</TargetFramework>
<AssemblyName>Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<LangVersion>6</LangVersion>
<RootNamespace>Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac, Version=4.6.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da">
<HintPath>..\packages\Autofac.4.6.0\lib\net45\Autofac.dll</HintPath>
</Reference>
<Reference Include="Autofac.Integration.Owin, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da">
<HintPath>..\packages\Autofac.Owin.4.0.0\lib\net45\Autofac.Integration.Owin.dll</HintPath>
</Reference>
<Reference Include="Autofac.Integration.WebApi, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da">
<HintPath>..\packages\Autofac.WebApi2.4.0.1\lib\net45\Autofac.Integration.WebApi.dll</HintPath>
</Reference>
<Reference Include="Autofac.Integration.WebApi.Owin, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da">
<HintPath>..\packages\Autofac.WebApi2.Owin.4.0.0\lib\net45\Autofac.Integration.WebApi.Owin.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNet.WebApi.Versioning, Version=2.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Versioning.2.0.3\lib\net45\Microsoft.AspNet.WebApi.Versioning.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.3.1.0\lib\net45\Microsoft.Owin.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.3.1.0\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Owin.Hosting, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Owin.Hosting.3.1.0\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http.Owin, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DependencyResolution.cs" />
<Compile Include="Runtime\ConfigData.cs" />
<Compile Include="Runtime\Uptime.cs" />
<Compile Include="v1\Controllers\DeviceTypesController.cs" />
<Compile Include="v1\Controllers\SimulationsController.cs" />
<Compile Include="v1\Controllers\StatusController.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Runtime\Config.cs" />
<Compile Include="Startup.cs" />
<Compile Include="v1\Exceptions\BadRequestException.cs" />
<Compile Include="v1\Filters\ExceptionsFilterAttribute.cs" />
<Compile Include="v1\Models\DeviceTypeApiModel.cs" />
<Compile Include="v1\Models\DeviceTypeListApiModel.cs" />
<Compile Include="v1\Models\SimulationApiModel.cs" />
<Compile Include="v1\Models\SimulationListApiModel.cs" />
<Compile Include="v1\Models\SimulationPatchApiModel.cs" />
<Compile Include="v1\Models\StatusApiModel.cs" />
<Compile Include="v1\Version.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="README.md" />
<Content Include="v1\Controllers\README.md" />
<Content Include="v1\Models\README.md" />
<PackageReference Include="Autofac" Version="4.6.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Services\Services.csproj">
<Project>{8acbc846-b16c-4857-94f1-0bb297fe1cd3}</Project>
<Name>Services</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Content Include="appsettings.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

Просмотреть файл

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="device-simulation.webservice.port" value="${PCS_SIMULATION_WEBSERVICE_PORT}"/>
<add key="device-simulation.device-types-folder" value="./data/DeviceTypes/"/>
<add key="device-simulation.device-types-behavior-folder" value="./data/scripts/"/>
<add key="iothubmanager.webservice.host" value="${PCS_IOTHUBMANAGER_WEBSERVICE_HOST}"/>
<add key="iothubmanager.webservice.port" value="${PCS_IOTHUBMANAGER_WEBSERVICE_PORT}"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

15
WebService/appsettings.ini Executable file
Просмотреть файл

@ -0,0 +1,15 @@
[Logging]
IncludeScopes = false
LogLevel:Default = Warning
LogLevel:System = Information
LogLevel:Microsoft = Information
[devicesimulation]
webservice_port = ${PCS_SIMULATION_WEBSERVICE_PORT}
device_types_folder = ./data/DeviceTypes/
device_types_behavior_folder = ./data/scripts/
[iothubmanager]
webservice_host = ${PCS_IOTHUBMANAGER_WEBSERVICE_HOST}
webservice_port = ${PCS_IOTHUBMANAGER_WEBSERVICE_PORT}
webservice_timeout = 10

Просмотреть файл

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="4.6.0" targetFramework="net462" />
<package id="Autofac.Owin" version="4.0.0" targetFramework="net462" />
<package id="Autofac.WebApi2" version="4.0.1" targetFramework="net462" />
<package id="Autofac.WebApi2.Owin" version="4.0.0" targetFramework="net462" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net462" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net462" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net462" />
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.3" targetFramework="net462" />
<package id="Microsoft.AspNet.WebApi.Versioning" version="2.0.3" targetFramework="net462" />
<package id="Microsoft.Owin" version="3.1.0" targetFramework="net462" />
<package id="Microsoft.Owin.Host.HttpListener" version="3.1.0" targetFramework="net462" />
<package id="Microsoft.Owin.Hosting" version="3.1.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net462" />
<package id="Owin" version="1.0" targetFramework="net462" />
</packages>

Просмотреть файл

@ -1,15 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Web.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Models;
using Microsoft.Web.Http;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controllers
{
[ApiVersion(Version.Number), ExceptionsFilter]
public class DeviceTypesController : ApiController
[Route(Version.Path + "/[controller]"), ExceptionsFilter]
public class DeviceTypesController : Controller
{
private readonly IDeviceTypes deviceTypesService;
@ -18,11 +17,13 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controller
this.deviceTypesService = deviceTypesService;
}
[HttpGet]
public DeviceTypeListApiModel Get()
{
return new DeviceTypeListApiModel(this.deviceTypesService.GetList());
}
[HttpGet("{id}")]
public DeviceTypeApiModel Get(string id)
{
return new DeviceTypeApiModel(this.deviceTypesService.Get(id));

Просмотреть файл

@ -1,16 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Web.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Exceptions;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Models;
using Microsoft.Web.Http;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controllers
{
[ApiVersion(Version.Number), ExceptionsFilter]
public class SimulationsController : ApiController
[Route(Version.Path + "/[controller]"), ExceptionsFilter]
public class SimulationsController : Controller
{
private readonly ISimulations simulationsService;
@ -19,19 +18,22 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controller
this.simulationsService = simulationsService;
}
[HttpGet]
public SimulationListApiModel Get()
{
return new SimulationListApiModel(this.simulationsService.GetList());
}
[HttpGet("{id}")]
public SimulationApiModel Get(string id)
{
return new SimulationApiModel(this.simulationsService.Get(id));
}
[HttpPost]
public SimulationApiModel Post(
SimulationApiModel simulation,
[FromUri(Name = "template")] string template = "")
[FromBody] SimulationApiModel simulation,
[FromQuery(Name = "template")] string template = "")
{
if (simulation == null)
{
@ -45,10 +47,11 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controller
this.simulationsService.Insert(simulation.ToServiceModel(), template));
}
[HttpPut("{id}")]
public SimulationApiModel Put(
SimulationApiModel simulation,
[FromBody] SimulationApiModel simulation,
string id = "",
[FromUri(Name = "template")] string template = "")
[FromQuery(Name = "template")] string template = "")
{
if (simulation == null)
{
@ -62,7 +65,10 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controller
this.simulationsService.Upsert(simulation.ToServiceModel(id), template));
}
public SimulationApiModel Patch(string id, SimulationPatchApiModel patch)
[HttpPatch("{id}")]
public SimulationApiModel Patch(
string id,
[FromBody] SimulationPatchApiModel patch)
{
if (patch == null) throw new BadRequestException("No data or invalid data provided");

Просмотреть файл

@ -1,15 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Web.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Models;
using Microsoft.Web.Http;
// TODO: complete
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Controllers
{
[ApiVersion(Version.Number), ExceptionsFilter]
public sealed class StatusController : ApiController
[Route(Version.Path + "/[controller]"), ExceptionsFilter]
public sealed class StatusController : Controller
{
public StatusApiModel Get()
{

Просмотреть файл

@ -1,17 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Filters;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.Services.Exceptions;
using Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Exceptions;
using Newtonsoft.Json;
//using System.Web.Http;
//using System.Web.Http.Filters;
namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters
{
@ -21,36 +22,34 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters
/// and preparing a JSON response with useful error details.
/// When including the stack trace, split the text in multiple lines
/// for an easier parsing.
///
/// @see https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters
/// </summary>
public class ExceptionsFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
public override void OnException(ExceptionContext context)
{
if (context.Exception is ResourceNotFoundException)
{
context.Response = this.GetResponse(HttpStatusCode.NotFound, context.Exception);
context.Result = this.GetResponse(HttpStatusCode.NotFound, context.Exception);
}
else if (context.Exception is ConflictingResourceException
|| context.Exception is ResourceOutOfDateException)
{
context.Response = this.GetResponse(HttpStatusCode.Conflict, context.Exception);
context.Result = this.GetResponse(HttpStatusCode.Conflict, context.Exception);
}
else if (context.Exception is BadRequestException
|| context.Exception is InvalidInputException)
{
context.Response = this.GetResponse(HttpStatusCode.BadRequest, context.Exception);
context.Result = this.GetResponse(HttpStatusCode.BadRequest, context.Exception);
}
else if (context.Exception is InvalidConfigurationException)
{
context.Response = this.GetResponse(HttpStatusCode.InternalServerError, context.Exception);
}
else if (context.Exception is HttpResponseException)
{
context.Response = ((HttpResponseException) context.Exception).Response;
context.Result = this.GetResponse(HttpStatusCode.InternalServerError, context.Exception);
}
else if (context.Exception != null)
{
context.Response = this.GetResponse(HttpStatusCode.InternalServerError, context.Exception, true);
context.Result = this.GetResponse(HttpStatusCode.InternalServerError, context.Exception, true);
}
else
{
@ -58,7 +57,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters
}
}
public override Task OnExceptionAsync(HttpActionExecutedContext context, CancellationToken token)
public override Task OnExceptionAsync(ExceptionContext context)
{
try
{
@ -66,7 +65,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters
}
catch (Exception)
{
return base.OnExceptionAsync(context, token);
return base.OnExceptionAsync(context);
}
return Task.FromResult(new VoidTask());
@ -76,7 +75,7 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters
{
}
private HttpResponseMessage GetResponse(
private ObjectResult GetResponse(
HttpStatusCode code,
Exception e,
bool stackTrace = false)
@ -101,13 +100,11 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.v1.Filters
}
}
return new HttpResponseMessage(code)
{
Content = new StringContent(
JsonConvert.SerializeObject(error),
Encoding.UTF8,
"application/json")
};
var result = new ObjectResult(error);
result.StatusCode = (int) code;
result.Formatters.Add(new JsonOutputFormatter(new JsonSerializerSettings(), ArrayPool<char>.Shared));
return result;
}
}
}

Просмотреть файл

@ -1,88 +1,88 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebService", "WebService\WebService.csproj", "{F305CAD5-BE38-4391-A692-580C526A0CB1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebService.Test", "WebService.Test\WebService.Test.csproj", "{6A4D86AD-56D0-421B-B9B2-2EBB34A5BBBC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution", "solution", "{8289AFAE-0933-40EF-9D19-6FFA2DB04837}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitconfig = .gitconfig
.gitignore = .gitignore
.travis.yml = .travis.yml
CONTRIBUTING.md = CONTRIBUTING.md
LICENSE = LICENSE
README.md = README.md
DEVELOPMENT.md = DEVELOPMENT.md
device-simulation.sln.DotSettings = device-simulation.sln.DotSettings
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services", "Services\Services.csproj", "{786A5B9B-98EE-4B73-9FE3-2080B70007AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services.Test", "Services.Test\Services.Test.csproj", "{1BC54189-1DF9-448E-AE5F-66EB2EF51D82}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitconfig = .gitconfig
.gitignore = .gitignore
.travis.yml = .travis.yml
CONTRIBUTING.md = CONTRIBUTING.md
LICENSE = LICENSE
README.md = README.md
DEVELOPMENT.md = DEVELOPMENT.md
device-simulation.sln.DotSettings = device-simulation.sln.DotSettings
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{7357A079-B54D-490F-AA91-1B7BDAFE5E3F}"
ProjectSection(SolutionItems) = preProject
scripts\.functions.sh = scripts\.functions.sh
scripts\build = scripts\build
scripts\build.cmd = scripts\build.cmd
scripts\clean-up = scripts\clean-up
scripts\clean-up.cmd = scripts\clean-up.cmd
scripts\compile = scripts\compile
scripts\compile.cmd = scripts\compile.cmd
scripts\run = scripts\run
scripts\run.cmd = scripts\run.cmd
scripts\run.vbs = scripts\run.vbs
scripts\build-in-sandbox = scripts\build-in-sandbox
scripts\build-in-sandbox.cmd = scripts\build-in-sandbox.cmd
scripts\compile-in-sandbox = scripts\compile-in-sandbox
scripts\compile-in-sandbox.cmd = scripts\compile-in-sandbox.cmd
scripts\run-in-sandbox = scripts\run-in-sandbox
scripts\run-in-sandbox.cmd = scripts\run-in-sandbox.cmd
scripts\env-vars-check = scripts\env-vars-check
scripts\env-vars-check.cmd = scripts\env-vars-check.cmd
scripts\env-vars-setup = scripts\env-vars-setup
EndProjectSection
ProjectSection(SolutionItems) = preProject
scripts\.functions.sh = scripts\.functions.sh
scripts\build = scripts\build
scripts\build.cmd = scripts\build.cmd
scripts\clean-up = scripts\clean-up
scripts\clean-up.cmd = scripts\clean-up.cmd
scripts\compile = scripts\compile
scripts\compile.cmd = scripts\compile.cmd
scripts\run = scripts\run
scripts\run.cmd = scripts\run.cmd
scripts\run.vbs = scripts\run.vbs
scripts\build-in-sandbox = scripts\build-in-sandbox
scripts\build-in-sandbox.cmd = scripts\build-in-sandbox.cmd
scripts\compile-in-sandbox = scripts\compile-in-sandbox
scripts\compile-in-sandbox.cmd = scripts\compile-in-sandbox.cmd
scripts\run-in-sandbox = scripts\run-in-sandbox
scripts\run-in-sandbox.cmd = scripts\run-in-sandbox.cmd
scripts\env-vars-check = scripts\env-vars-check
scripts\env-vars-check.cmd = scripts\env-vars-check.cmd
scripts\env-vars-setup = scripts\env-vars-setup
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "git", "git", "{FE64576E-E29D-4463-ABDA-93DB429A5F2F}"
ProjectSection(SolutionItems) = preProject
scripts\git\pre-commit-runner-no-sandbox.sh = scripts\git\pre-commit-runner-no-sandbox.sh
scripts\git\pre-commit-runner-with-sandbox.sh = scripts\git\pre-commit-runner-with-sandbox.sh
scripts\git\pre-commit.sh = scripts\git\pre-commit.sh
scripts\git\setup = scripts\git\setup
scripts\git\setup.cmd = scripts\git\setup.cmd
scripts\git\fix-perms.sh = scripts\git\fix-perms.sh
EndProjectSection
ProjectSection(SolutionItems) = preProject
scripts\git\pre-commit-runner-no-sandbox.sh = scripts\git\pre-commit-runner-no-sandbox.sh
scripts\git\pre-commit-runner-with-sandbox.sh = scripts\git\pre-commit-runner-with-sandbox.sh
scripts\git\pre-commit.sh = scripts\git\pre-commit.sh
scripts\git\setup = scripts\git\setup
scripts\git\setup.cmd = scripts\git\setup.cmd
scripts\git\fix-perms.sh = scripts\git\fix-perms.sh
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iothub", "iothub", "{62782BA5-0E78-4354-9962-B5F2CF3B5204}"
ProjectSection(SolutionItems) = preProject
scripts\iothub\.functions.sh = scripts\iothub\.functions.sh
scripts\iothub\create-hub.sh = scripts\iothub\create-hub.sh
scripts\iothub\list-hubs.sh = scripts\iothub\list-hubs.sh
scripts\iothub\list-subscriptions.sh = scripts\iothub\list-subscriptions.sh
scripts\iothub\select-subscription.sh = scripts\iothub\select-subscription.sh
scripts\iothub\show-hub.sh = scripts\iothub\show-hub.sh
EndProjectSection
ProjectSection(SolutionItems) = preProject
scripts\iothub\.functions.sh = scripts\iothub\.functions.sh
scripts\iothub\create-hub.sh = scripts\iothub\create-hub.sh
scripts\iothub\list-hubs.sh = scripts\iothub\list-hubs.sh
scripts\iothub\list-subscriptions.sh = scripts\iothub\list-subscriptions.sh
scripts\iothub\select-subscription.sh = scripts\iothub\select-subscription.sh
scripts\iothub\show-hub.sh = scripts\iothub\show-hub.sh
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{DB8AF4E5-71A1-4650-A881-9F08FCB53DAA}"
ProjectSection(SolutionItems) = preProject
scripts\docker\.dockerignore = scripts\docker\.dockerignore
scripts\docker\Dockerfile = scripts\docker\Dockerfile
scripts\docker\build = scripts\docker\build
scripts\docker\build.cmd = scripts\docker\build.cmd
scripts\docker\run = scripts\docker\run
scripts\docker\run.cmd = scripts\docker\run.cmd
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimulationAgent", "SimulationAgent\SimulationAgent.csproj", "{3739A325-246D-48C7-A59F-A355BEA0E6DF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimulationAgent.Test", "SimulationAgent.Test\SimulationAgent.Test.csproj", "{EF2B3E7D-4FFA-4B63-9E36-BDE17273D38B}"
ProjectSection(SolutionItems) = preProject
scripts\docker\.dockerignore = scripts\docker\.dockerignore
scripts\docker\Dockerfile = scripts\docker\Dockerfile
scripts\docker\build = scripts\docker\build
scripts\docker\build.cmd = scripts\docker\build.cmd
scripts\docker\run = scripts\docker\run
scripts\docker\run.cmd = scripts\docker\run.cmd
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{47397605-F212-4576-9F63-AC35405DC3B6}"
ProjectSection(SolutionItems) = preProject
scripts\docker\content\run.sh = scripts\docker\content\run.sh
EndProjectSection
ProjectSection(SolutionItems) = preProject
scripts\docker\content\run.sh = scripts\docker\content\run.sh
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services", "Services\Services.csproj", "{1856B3A0-3FF0-4E2B-9F82-6BD8260C4F40}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Services.Test", "Services.Test\Services.Test.csproj", "{728666A7-4789-4938-A9A5-F1897518D577}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimulationAgent", "SimulationAgent\SimulationAgent.csproj", "{7B96EB80-C678-4B92-BED3-9CB08FE8C6D1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimulationAgent.Test", "SimulationAgent.Test\SimulationAgent.Test.csproj", "{C1BD168A-4CA9-4AEC-AB59-F6023EC34456}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebService", "WebService\WebService.csproj", "{7E275AE4-F7E1-49C7-9937-78615FDAE192}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebService.Test", "WebService.Test\WebService.Test.csproj", "{F140A752-C57B-4C93-AF6B-31DA1B19CD13}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -90,30 +90,34 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F305CAD5-BE38-4391-A692-580C526A0CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F305CAD5-BE38-4391-A692-580C526A0CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F305CAD5-BE38-4391-A692-580C526A0CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F305CAD5-BE38-4391-A692-580C526A0CB1}.Release|Any CPU.Build.0 = Release|Any CPU
{6A4D86AD-56D0-421B-B9B2-2EBB34A5BBBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A4D86AD-56D0-421B-B9B2-2EBB34A5BBBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A4D86AD-56D0-421B-B9B2-2EBB34A5BBBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A4D86AD-56D0-421B-B9B2-2EBB34A5BBBC}.Release|Any CPU.Build.0 = Release|Any CPU
{786A5B9B-98EE-4B73-9FE3-2080B70007AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{786A5B9B-98EE-4B73-9FE3-2080B70007AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{786A5B9B-98EE-4B73-9FE3-2080B70007AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{786A5B9B-98EE-4B73-9FE3-2080B70007AF}.Release|Any CPU.Build.0 = Release|Any CPU
{1BC54189-1DF9-448E-AE5F-66EB2EF51D82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BC54189-1DF9-448E-AE5F-66EB2EF51D82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BC54189-1DF9-448E-AE5F-66EB2EF51D82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BC54189-1DF9-448E-AE5F-66EB2EF51D82}.Release|Any CPU.Build.0 = Release|Any CPU
{3739A325-246D-48C7-A59F-A355BEA0E6DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3739A325-246D-48C7-A59F-A355BEA0E6DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3739A325-246D-48C7-A59F-A355BEA0E6DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3739A325-246D-48C7-A59F-A355BEA0E6DF}.Release|Any CPU.Build.0 = Release|Any CPU
{EF2B3E7D-4FFA-4B63-9E36-BDE17273D38B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EF2B3E7D-4FFA-4B63-9E36-BDE17273D38B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF2B3E7D-4FFA-4B63-9E36-BDE17273D38B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF2B3E7D-4FFA-4B63-9E36-BDE17273D38B}.Release|Any CPU.Build.0 = Release|Any CPU
{90A4CAAB-F071-4CF8-A87C-C7F094258F13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90A4CAAB-F071-4CF8-A87C-C7F094258F13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90A4CAAB-F071-4CF8-A87C-C7F094258F13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90A4CAAB-F071-4CF8-A87C-C7F094258F13}.Release|Any CPU.Build.0 = Release|Any CPU
{1856B3A0-3FF0-4E2B-9F82-6BD8260C4F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1856B3A0-3FF0-4E2B-9F82-6BD8260C4F40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1856B3A0-3FF0-4E2B-9F82-6BD8260C4F40}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1856B3A0-3FF0-4E2B-9F82-6BD8260C4F40}.Release|Any CPU.Build.0 = Release|Any CPU
{728666A7-4789-4938-A9A5-F1897518D577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{728666A7-4789-4938-A9A5-F1897518D577}.Debug|Any CPU.Build.0 = Debug|Any CPU
{728666A7-4789-4938-A9A5-F1897518D577}.Release|Any CPU.ActiveCfg = Release|Any CPU
{728666A7-4789-4938-A9A5-F1897518D577}.Release|Any CPU.Build.0 = Release|Any CPU
{7B96EB80-C678-4B92-BED3-9CB08FE8C6D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B96EB80-C678-4B92-BED3-9CB08FE8C6D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B96EB80-C678-4B92-BED3-9CB08FE8C6D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B96EB80-C678-4B92-BED3-9CB08FE8C6D1}.Release|Any CPU.Build.0 = Release|Any CPU
{C1BD168A-4CA9-4AEC-AB59-F6023EC34456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C1BD168A-4CA9-4AEC-AB59-F6023EC34456}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1BD168A-4CA9-4AEC-AB59-F6023EC34456}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1BD168A-4CA9-4AEC-AB59-F6023EC34456}.Release|Any CPU.Build.0 = Release|Any CPU
{7E275AE4-F7E1-49C7-9937-78615FDAE192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E275AE4-F7E1-49C7-9937-78615FDAE192}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E275AE4-F7E1-49C7-9937-78615FDAE192}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E275AE4-F7E1-49C7-9937-78615FDAE192}.Release|Any CPU.Build.0 = Release|Any CPU
{F140A752-C57B-4C93-AF6B-31DA1B19CD13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F140A752-C57B-4C93-AF6B-31DA1B19CD13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F140A752-C57B-4C93-AF6B-31DA1B19CD13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F140A752-C57B-4C93-AF6B-31DA1B19CD13}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Просмотреть файл

@ -17,10 +17,53 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTTP/@EntryIndexedValue">HTTP</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=JSON/@EntryIndexedValue">JSON</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MQTT/@EntryIndexedValue">MQTT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSL/@EntryIndexedValue">SSL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UID/@EntryIndexedValue">UID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=StaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FCONSTANT/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FBLOCK_005FSCOPE_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FCLASS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FCONSTRUCTOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FGLOBAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLABEL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLOCAL_005FCONSTRUCTOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FLOCAL_005FVARIABLE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FOBJECT_005FPROPERTY_005FOF_005FFUNCTION/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FCLASS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FENUM/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FENUM_005FMEMBER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FINTERFACE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="I" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE_005FEXPORTED/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FMODULE_005FLOCAL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPRIVATE_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPROTECTED_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FMEMBER_005FACCESSOR/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FSTATIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FPUBLIC_005FTYPE_005FMETHOD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FTYPE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=TS_005FTYPE_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FHTML_005FCONTROL/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FTAG_005FNAME/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/WebNaming/UserRules/=ASP_005FTAG_005FPREFIX/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=NAMESPACE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/PsiConfigurationSettingsKey/CustomLocation/@EntryValue">C:\Users\delucato\AppData\Local\JetBrains\Transient\ReSharperPlatformVs15\v08_21405b6a\SolutionCaches</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>

Просмотреть файл

@ -13,42 +13,6 @@ error() {
echo -e "${COL_ERR}$1 ${COL_NO}"
}
check_dependency_nuget() {
set +e
TEST=$(which nuget)
if [[ -z "$TEST" ]]; then
echo "ERROR: 'nuget' command not found."
echo "Install Mono 5.x and the 'nuget' package, and make sure the 'nuget' command is in the PATH."
echo "Mono installation: http://www.mono-project.com/docs/getting-started/install"
exit 1
fi
set -e
}
check_dependency_msbuild() {
set +e
TEST=$(which msbuild)
if [[ -z "$TEST" ]]; then
echo "ERROR: 'msbuild' command not found."
echo "Install Mono 5.x and the 'msbuild' package, and make sure the 'nuget' command is in the PATH."
echo "Mono installation: http://www.mono-project.com/docs/getting-started/install"
exit 1
fi
set -e
}
check_dependency_mono() {
set +e
TEST=$(which mono)
if [[ -z "$TEST" ]]; then
echo "ERROR: 'msbuild' command not found."
echo "Install Mono 5.x and make sure the 'mono' command is in the PATH."
echo "Mono installation: http://www.mono-project.com/docs/getting-started/install"
exit 1
fi
set -e
}
check_dependency_dotnet() {
set +e
TEST=$(which dotnet)

Просмотреть файл

@ -8,27 +8,25 @@ APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"
compile() {
check_dependency_nuget
check_dependency_msbuild
check_dependency_dotnet
cd $APP_HOME
header "Downloading dependencies..."
nuget restore
dotnet restore
header "Compiling code..."
msbuild /p:Configuration=$CONFIGURATION
dotnet build --configuration $CONFIGURATION
}
run_tests() {
check_dependency_dotnet
check_dependency_mono
cd $APP_HOME
header "Running tests..."
PROJECTS=$(dotnet sln list | grep 'csproj$' | grep '\.Test'| sed s#/.*##)
PROJECTS=$(dotnet sln list | grep 'csproj$' | grep '\.Test')
for PROJ in $PROJECTS; do
echo "-- $PROJ"
mono ./packages/xunit.runner.console.2.2.0/tools/xunit.console.exe $PROJ/bin/Release/$PROJ.dll
dotnet test $PROJ
done
}

Просмотреть файл

@ -28,7 +28,7 @@ build_in_sandbox() {
-v "$APP_HOME/.cache/sandbox/.dotnet:/root/.dotnet" \
-v "$APP_HOME/.cache/sandbox/.nuget:/root/.nuget" \
-v "$APP_HOME:/opt/code" \
azureiotpcs/code-builder-dotnet:1.0 /opt/scripts/build
azureiotpcs/code-builder-dotnet:1.0-dotnetcore /opt/scripts/build
else
cmd.exe /c ".\scripts\build-in-sandbox.cmd"
fi

Просмотреть файл

@ -21,7 +21,7 @@ docker run ^
-v %APP_HOME%\.cache\sandbox\.dotnet:/root/.dotnet ^
-v %APP_HOME%\.cache\sandbox\.nuget:/root/.nuget ^
-v %APP_HOME%:/opt/code ^
azureiotpcs/code-builder-dotnet:1.0 /opt/scripts/build
azureiotpcs/code-builder-dotnet:1.0-dotnetcore /opt/scripts/build
:: Error 125 typically triggers on Windows if the drive is not shared
IF %ERRORLEVEL% EQU 125 GOTO DOCKER_SHARE

Просмотреть файл

@ -10,45 +10,31 @@ SET APP_HOME=%APP_HOME:~0,-9%
cd %APP_HOME%
:: Check dependencies
nuget > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_NUGET
msbuild /version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_MSBUILD
dotnet --version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_DOTNET
:: Restore nuget packages and compile the application
echo Downloading dependencies...
call nuget restore
call dotnet restore
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
echo Compiling code...
call msbuild /m /p:Configuration=%CONFIGURATION%;Platform="Any CPU"
call dotnet build --configuration %CONFIGURATION%
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
:: Find all the test assemblies and run the tests with XUnit runner
echo Running tests...
SET PATTERN=bin\%CONFIGURATION%
for /r %%i in (*.Test.dll) do (
echo.%%i | findstr /C:%PATTERN% >nul
IF !ERRORLEVEL! EQU 0 (
echo === %%i
.\packages\xunit.runner.console.2.2.0\tools\xunit.console.exe %%i -verbose -nologo -noshadow -parallel all
IF %ERRORLEVEL% EQU 1 GOTO FAIL
)
for /d %%i in (*.Test) do (
dotnet test %%i\%%i.csproj
IF !ERRORLEVEL! NEQ 0 GOTO FAIL
)
:: - - - - - - - - - - - - - -
goto :END
:MISSING_NUGET
echo ERROR: 'nuget' command not found.
echo Install Nuget CLI and make sure the 'nuget' command is in the PATH.
echo Nuget installation: https://docs.microsoft.com/en-us/nuget/guides/install-nuget
exit /B 1
:MISSING_MSBUILD
echo ERROR: 'msbuild' command not found.
echo Install Visual Studio IDE and make sure the 'msbuild' command is in the PATH.
echo Visual Studio installation: https://docs.microsoft.com/visualstudio/install
echo MSBuild installation without Visual Studio: http://stackoverflow.com/questions/42696948
:MISSING_DOTNET
echo ERROR: 'dotnet' command not found.
echo Install .NET Core 1.1.2 and make sure the 'dotnet' command is in the PATH.
echo Nuget installation: https://dotnet.github.io/
exit /B 1
:FAIL

Просмотреть файл

@ -5,13 +5,12 @@ APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"
compile() {
check_dependency_nuget
check_dependency_msbuild
check_dependency_dotnet
cd $APP_HOME
nuget restore
msbuild /m /p:Configuration=Debug
msbuild /m /p:Configuration=Release
dotnet restore
dotnet build --configuration Debug
dotnet build --configuration Release
}
compile_in_sandbox() {

Просмотреть файл

@ -28,7 +28,7 @@ compile_in_sandbox() {
-v "$APP_HOME/.cache/sandbox/.dotnet:/root/.dotnet" \
-v "$APP_HOME/.cache/sandbox/.nuget:/root/.nuget" \
-v "$APP_HOME:/opt/code" \
azureiotpcs/code-builder-dotnet:1.0 /opt/scripts/compile
azureiotpcs/code-builder-dotnet:1.0-dotnetcore /opt/scripts/compile
else
# Note 'winpty' is required to provide a TTY to Docker
cmd.exe /c "winpty .\scripts\compile-in-sandbox.cmd"

Просмотреть файл

@ -21,7 +21,7 @@ docker run -it ^
-v %APP_HOME%\.cache\sandbox\.dotnet:/root/.dotnet ^
-v %APP_HOME%\.cache\sandbox\.nuget:/root/.nuget ^
-v %APP_HOME%:/opt/code ^
azureiotpcs/code-builder-dotnet:1.0 /opt/scripts/compile
azureiotpcs/code-builder-dotnet:1.0-dotnetcore /opt/scripts/compile
:: Error 125 typically triggers on Windows if the drive is not shared
IF %ERRORLEVEL% EQU 125 GOTO DOCKER_SHARE

Просмотреть файл

@ -7,33 +7,24 @@ SET APP_HOME=%APP_HOME:~0,-9%
cd %APP_HOME%
:: Check dependencies
nuget > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_NUGET
msbuild /version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_MSBUILD
dotnet --version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_DOTNET
:: Restore nuget packages and compile the application with both Debug and Release configurations
call nuget restore
call dotnet restore
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
call msbuild /m /p:Configuration=Debug;Platform="Any CPU"
call dotnet build --configuration Debug
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
call msbuild /m /p:Configuration=Release;Platform="Any CPU"
call dotnet build --configuration Release
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
:: - - - - - - - - - - - - - -
goto :END
:MISSING_NUGET
echo ERROR: 'nuget' command not found.
echo Install Nuget CLI and make sure the 'nuget' command is in the PATH.
echo Nuget installation: https://docs.microsoft.com/en-us/nuget/guides/install-nuget
exit /B 1
:MISSING_MSBUILD
echo ERROR: 'msbuild' command not found.
echo Install Visual Studio IDE and make sure the 'msbuild' command is in the PATH.
echo Visual Studio installation: https://docs.microsoft.com/visualstudio/install
echo MSBuild installation without Visual Studio: http://stackoverflow.com/questions/42696948
:MISSING_DOTNET
echo ERROR: 'dotnet' command not found.
echo Install .NET Core 1.1.2 and make sure the 'dotnet' command is in the PATH.
echo Nuget installation: https://dotnet.github.io/
exit /B 1
:FAIL

Просмотреть файл

@ -1,4 +1,4 @@
FROM mono:latest
FROM microsoft/dotnet:1.1.2-runtime-jessie
MAINTAINER Devis Lucato (https://github.com/dluc)

Просмотреть файл

@ -11,24 +11,31 @@ APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"
compile() {
check_dependency_nuget
check_dependency_msbuild
check_dependency_dotnet
cd $APP_HOME
nuget restore
msbuild /m /p:Configuration=$CONFIGURATION
dotnet restore
dotnet build --configuration $CONFIGURATION
}
build_docker_image() {
check_dependency_docker
cd $APP_HOME
rm -fR out/docker
rm -fR WebService/bin/Docker
rm -fR SimulationAgent/bin/Docker
mkdir -p out/docker/webservice
mkdir -p out/docker/simulationagent
cp -pR WebService/bin/$CONFIGURATION/* out/docker/webservice/
cp -pR SimulationAgent/bin/$CONFIGURATION/* out/docker/simulationagent/
dotnet publish WebService --configuration $CONFIGURATION --output bin/Docker
dotnet publish SimulationAgent --configuration $CONFIGURATION --output bin/Docker
cp -pR WebService/bin/Docker/* out/docker/webservice/
cp -pR SimulationAgent/bin/Docker/* out/docker/simulationagent/
cp scripts/docker/.dockerignore out/docker/
cp scripts/docker/Dockerfile out/docker/
cp scripts/docker/content/run.sh out/docker/

Просмотреть файл

@ -13,26 +13,31 @@ SET APP_HOME=%APP_HOME:~0,-16%
cd %APP_HOME%
:: Check dependencies
nuget > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_NUGET
msbuild /version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_MSBUILD
dotnet --version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_DOTNET
docker version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_DOCKER
:: Restore packages and build the application
call nuget restore
call dotnet restore
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
call msbuild /m /p:Configuration=%CONFIGURATION%;Platform="Any CPU"
call dotnet build --configuration %CONFIGURATION%
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
:: Build the container image
rmdir /s /q out\docker
rmdir /s /q WebService\bin\Docker
rmdir /s /q SimulationAgent\bin\Docker
mkdir out\docker\webservice
mkdir out\docker\simulationagent
xcopy /s WebService\bin\%CONFIGURATION%\* out\docker\webservice\
xcopy /s SimulationAgent\bin\%CONFIGURATION%\* out\docker\simulationagent\
dotnet publish WebService --configuration %CONFIGURATION% --output bin\Docker
dotnet publish SimulationAgent --configuration %CONFIGURATION% --output bin\Docker
xcopy /s WebService\bin\Docker\* out\docker\webservice\
xcopy /s SimulationAgent\bin\Docker\* out\docker\simulationagent\
copy scripts\docker\.dockerignore out\docker\
copy scripts\docker\Dockerfile out\docker\
copy scripts\docker\content\run.sh out\docker\
@ -44,17 +49,10 @@ IF %ERRORLEVEL% NEQ 0 GOTO FAIL
:: - - - - - - - - - - - - - -
goto :END
:MISSING_NUGET
echo ERROR: 'nuget' command not found.
echo Install Nuget CLI and make sure the 'nuget' command is in the PATH.
echo Nuget installation: https://docs.microsoft.com/en-us/nuget/guides/install-nuget
exit /B 1
:MISSING_MSBUILD
echo ERROR: 'msbuild' command not found.
echo Install Visual Studio IDE and make sure the 'msbuild' command is in the PATH.
echo Visual Studio installation: https://docs.microsoft.com/visualstudio/install
echo MSBuild installation without Visual Studio: http://stackoverflow.com/questions/42696948
:MISSING_DOTNET
echo ERROR: 'dotnet' command not found.
echo Install .NET Core 1.1.2 and make sure the 'dotnet' command is in the PATH.
echo Nuget installation: https://dotnet.github.io/
exit /B 1
:MISSING_DOCKER

Просмотреть файл

@ -2,6 +2,6 @@
cd /app/
cd webservice && mono Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.exe --background & \
cd simulationagent && mono Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.exe && \
cd webservice && dotnet Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.dll --background & \
cd simulationagent && dotnet Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.dll && \
fg

Просмотреть файл

@ -7,8 +7,8 @@ usage() {
echo "ERROR: sandboxing mode not specified."
echo ""
echo "The pre-commit hook can run in two different modes:"
echo " With sandbox: the build script runs inside a Docker container so you need to install only Docker"
echo " Without sandbox: the build script runs using binaries like Mono, MSBuild and Nuget from your workstation"
echo " With sandbox: the build process runs inside a Docker container so you don't need to install .NET Core and other dependencies"
echo " Without sandbox: the build process runs using .NET Core and other dependencies from your workstation"
echo ""
echo "Usage:"
echo "./scripts/git/setup --with-sandbox"

Просмотреть файл

@ -35,8 +35,8 @@ goto :USAGE
echo ERROR: sandboxing mode not specified.
echo.
echo The pre-commit hook can run in two different modes:
echo With sandbox: the build script runs inside a Docker container so you need to install only Docker
echo Without sandbox: the build script runs using binaries like Mono, MSBuild and Nuget from your workstation
echo With sandbox: the build process runs inside a Docker container so you don't need to install .NET Core and other dependencies
echo Without sandbox: the build process runs using .NET Core and other dependencies from your workstation
echo.
echo Usage:
echo .\scripts\git\setup --with-sandbox

Просмотреть файл

@ -8,22 +8,17 @@ APP_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )/"
source "$APP_HOME/scripts/.functions.sh"
run() {
check_dependency_nuget
check_dependency_msbuild
check_dependency_mono
cd $APP_HOME
echo "Building..."
nuget restore
msbuild /m /p:Configuration=$CONFIGURATION /verbosity:quiet
check_dependency_dotnet
./scripts/env-vars-check
cd $APP_HOME
dotnet restore --verbosity=quiet
echo "Starting simulation agent and web service..."
cd $APP_HOME/SimulationAgent/bin/$CONFIGURATION/ && \
mono Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.exe & \
cd $APP_HOME/WebService/bin/$CONFIGURATION/ && \
mono Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.exe --background && \
dotnet run --configuration $CONFIGURATION --project SimulationAgent/*.csproj & \
dotnet run --configuration $CONFIGURATION --project WebService/*.csproj --background && \
fg
}

Просмотреть файл

@ -35,7 +35,7 @@ run_in_sandbox() {
-v "$APP_HOME/.cache/sandbox/.dotnet:/root/.dotnet" \
-v "$APP_HOME/.cache/sandbox/.nuget:/root/.nuget" \
-v "$APP_HOME:/opt/code" \
azureiotpcs/code-builder-dotnet:1.0 /opt/scripts/run
azureiotpcs/code-builder-dotnet:1.0-dotnetcore /opt/scripts/run
else
# Note 'winpty' is required to provide a TTY to Docker
cmd.exe /c "winpty .\scripts\run-in-sandbox.cmd"

Просмотреть файл

@ -29,7 +29,7 @@ docker run -it ^
-v %APP_HOME%\.cache\sandbox\.dotnet:/root/.dotnet ^
-v %APP_HOME%\.cache\sandbox\.nuget:/root/.nuget ^
-v %APP_HOME%:/opt/code ^
azureiotpcs/code-builder-dotnet:1.0 /opt/scripts/run
azureiotpcs/code-builder-dotnet:1.0-dotnetcore /opt/scripts/run
:: Error 125 typically triggers on Windows if the drive is not shared
IF %ERRORLEVEL% EQU 125 GOTO DOCKER_SHARE

Просмотреть файл

@ -10,44 +10,30 @@ SET APP_HOME=%APP_HOME:~0,-9%
cd %APP_HOME%
:: Check dependencies
nuget > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_NUGET
msbuild /version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_MSBUILD
:: Restore nuget packages and compile the application
call nuget restore
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
call msbuild /m /p:Configuration=%CONFIGURATION%;Platform="Any CPU"
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
dotnet --version > NUL 2>&1
IF %ERRORLEVEL% NEQ 0 GOTO MISSING_DOTNET
:: Check settings
call .\scripts\env-vars-check.cmd
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
:: Run with elevated privileges
copy .\scripts\run.vbs .\WebService\bin\%CONFIGURATION%
cd WebService\bin\%CONFIGURATION%
call cscript run.vbs "Microsoft.Azure.IoTSolutions.DeviceSimulation.WebService.exe --background"
:: Restore nuget packages and compile the application
call dotnet restore
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
copy .\scripts\run.vbs .\SimulationAgent\bin\%CONFIGURATION%
cd SimulationAgent\bin\%CONFIGURATION%
call cscript run.vbs "Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.exe"
start "" dotnet run --configuration %CONFIGURATION% --project SimulationAgent/SimulationAgent.csproj
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
start "" dotnet run --configuration %CONFIGURATION% --project WebService/WebService.csproj --background
IF %ERRORLEVEL% NEQ 0 GOTO FAIL
:: - - - - - - - - - - - - - -
goto :END
:MISSING_NUGET
echo ERROR: 'nuget' command not found.
echo Install Nuget CLI and make sure the 'nuget' command is in the PATH.
echo Nuget installation: https://docs.microsoft.com/en-us/nuget/guides/install-nuget
exit /B 1
:MISSING_MSBUILD
echo ERROR: 'msbuild' command not found.
echo Install Visual Studio IDE and make sure the 'msbuild' command is in the PATH.
echo Visual Studio installation: https://docs.microsoft.com/visualstudio/install
echo MSBuild installation without Visual Studio: http://stackoverflow.com/questions/42696948
:MISSING_DOTNET
echo ERROR: 'dotnet' command not found.
echo Install .NET Core 1.1.2 and make sure the 'dotnet' command is in the PATH.
echo Nuget installation: https://dotnet.github.io/
exit /B 1
:FAIL