Skip to content

Commit 641ce78

Browse files
authored
Merge pull request #57511 from craigshoemaker/crs-func-csharp-ref
Update project.json to project.csproj
2 parents 9fc43ab + ffc7154 commit 641ce78

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

articles/azure-functions/functions-reference-csharp.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -372,34 +372,27 @@ For information on how to upload files to your function folder, see the section
372372
The directory that contains the function script file is automatically watched for changes to assemblies. To watch for assembly changes in other directories, add them to the `watchDirectories` list in [host.json](functions-host-json.md).
373373

374374
## Using NuGet packages
375-
376-
To use NuGet packages in a C# function, upload a *project.json* file to the function's folder in the function app's file system. Here is an example *project.json* file that adds a reference to Microsoft.ProjectOxford.Face version 1.1.0:
377-
378-
```json
379-
{
380-
"frameworks": {
381-
"net46":{
382-
"dependencies": {
383-
"Microsoft.ProjectOxford.Face": "1.1.0"
384-
}
385-
}
386-
}
387-
}
375+
To use NuGet packages in a C# function, upload a *extensions.csproj* file to the function's folder in the function app's file system. Here is an example *extensions.csproj* file that adds a reference to *Microsoft.ProjectOxford.Face* version *1.1.0*:
376+
377+
```xml
378+
<Project Sdk="Microsoft.NET.Sdk">
379+
<PropertyGroup>
380+
<TargetFramework>net46</TargetFramework>
381+
</PropertyGroup>
382+
383+
<ItemGroup>
384+
<PackageReference Include="Microsoft.ProjectOxford.Face" Version="1.1.0" />
385+
</ItemGroup>
386+
</Project>
388387
```
389388

390-
In Azure Functions 1.x, only the .NET Framework 4.6 is supported, so make sure that your *project.json* file specifies `net46` as shown here.
391-
392-
When you upload a *project.json* file, the runtime gets the packages and automatically adds references to the package assemblies. You don't need to add `#r "AssemblyName"` directives. To use the types defined in the NuGet packages; just add the required `using` statements to your *run.csx* file.
393-
394-
In the Functions runtime, NuGet restore works by comparing `project.json` and `project.lock.json`. If the date and time stamps of the files **do not** match, a NuGet restore runs and NuGet downloads updated packages. However, if the date and time stamps of the files **do** match, NuGet does not perform a restore. Therefore, `project.lock.json` should not be deployed, as it causes NuGet to skip package restore. To avoid deploying the lock file, add the `project.lock.json` to the `.gitignore` file.
395-
396389
To use a custom NuGet feed, specify the feed in a *Nuget.Config* file in the Function App root. For more information, see [Configuring NuGet behavior](/nuget/consume-packages/configuring-nuget-behavior).
397390

398-
### Using a project.json file
391+
### Using a extensions.csproj file
399392

400393
1. Open the function in the Azure portal. The logs tab displays the package installation output.
401-
2. To upload a project.json file, use one of the methods described in the [How to update function app files](functions-reference.md#fileupdate) in the Azure Functions developer reference topic.
402-
3. After the *project.json* file is uploaded, you see output like the following example in your function's streaming log:
394+
2. To upload a *extensions.csproj* file, use one of the methods described in the [How to update function app files](functions-reference.md#fileupdate) in the Azure Functions developer reference topic.
395+
3. After the *extensions.csproj* file is uploaded, you see output like the following example in your function's streaming log:
403396

404397
```
405398
2016-04-04T19:02:48.745 Restoring packages.
@@ -409,7 +402,7 @@ To use a custom NuGet feed, specify the feed in a *Nuget.Config* file in the Fun
409402
2016-04-04T19:02:50.261 C:\DWASFiles\Sites\facavalfunctest\LocalAppData\NuGet\Cache
410403
2016-04-04T19:02:50.261 https://api.nuget.org/v3/index.json
411404
2016-04-04T19:02:50.261
412-
2016-04-04T19:02:50.511 Restoring packages for D:\home\site\wwwroot\HttpTriggerCSharp1\Project.json...
405+
2016-04-04T19:02:50.511 Restoring packages for D:\home\site\wwwroot\HttpTriggerCSharp1\extensions.csproj...
413406
2016-04-04T19:02:52.800 Installing Newtonsoft.Json 6.0.8.
414407
2016-04-04T19:02:52.800 Installing Microsoft.ProjectOxford.Face 1.1.0.
415408
2016-04-04T19:02:57.095 All packages are compatible with .NETFramework,Version=v4.6.

0 commit comments

Comments
 (0)