Skip to content

Commit 2c6c3f7

Browse files
Learn Build Service GitHub AppLearn Build Service GitHub App
authored andcommitted
Merging changes synced from https://github.com/MicrosoftDocs/visualstudio-docs-pr (branch live)
2 parents 18e6389 + 027122b commit 2c6c3f7

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

docs/msbuild/writecodefragment-task.md

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: WriteCodeFragment Task | Microsoft Docs
3-
description: Learn how MSBuild uses the WriteCodeFragment task to generates a temporary code file from the specified generated code fragment.
4-
ms.date: 11/04/2016
3+
description: Learn how MSBuild uses the WriteCodeFragment task to generate a temporary code file from the specified generated code fragment.
4+
ms.date: 07/26/2023
55
ms.topic: reference
66
dev_langs:
77
- VB
@@ -29,14 +29,79 @@ Generates a temporary code file from the specified generated code fragment. Does
2929

3030
|Parameter|Description|
3131
|---------------|-----------------|
32-
|`AssemblyAttributes`|Optional <xref:Microsoft.Build.Framework.ITaskItem>`[]` parameter.<br /><br /> Description of the attributes to write. The item `Include` value is the full type name of the attribute, for example, "System.AssemblyVersionAttribute".<br /><br /> Each metadata is the name-value pair of a parameter, which must be of type `String`. Some attributes only allow positional constructor arguments. However, you can use such arguments in any attribute. To set positional constructor attributes, use metadata names that resemble "_Parameter1", "_Parameter2", and so on.<br /><br /> A parameter index cannot be skipped.|
33-
|`Language`|Required `String` parameter.<br /><br /> Specifies the language of the code to generate.<br /><br /> `Language` can be any language for which a CodeDom provider is available, for example, "C#" or "VisualBasic". The emitted file will have the default file name extension for that language.|
32+
|`AssemblyAttributes`|Optional <xref:Microsoft.Build.Framework.ITaskItem>`[]` parameter.<br /><br /> Description of the attributes to write. The item `Include` value is the full type name of the attribute, for example, `System.AssemblyVersionAttribute`.<br /><br /> Each metadata is the name-value pair of a parameter. Parameters are assumed to be of type `String` in MSBuild 17.6 and earlier, but in MSBuild 17.7 and later, you can also use types other than `String` that are part of `mscorlib`. For example, you can use `true` and `false` Boolean values, integers, enums, and floating point types. The type is automatically inferred from the syntax. For a type not in `mscorlib`, specify the type for the parameter by providing metadata values in the form `{parameter}_TypeName`.<br/><br/>Some attributes only allow positional constructor arguments. However, you can use such arguments in any attribute. To set positional constructor attributes, use metadata names that resemble `_Parameter1`, `_Parameter2`, and so on. A parameter index can't be skipped.<br/><br/>In MSBuild 17.7 or later, you can also specify metadata of the form `{parameter}_IsLiteral` to instruct the task to interpret the parameter value text as is, without surrounding with quotes (as is done in the default case for string values). |
33+
|`Language`|Required `String` parameter.<br /><br /> Specifies the language of the code to generate.<br /><br /> `Language` can be any language for which a CodeDom provider is available, for example, "C#" or "VisualBasic." The emitted file will have the default file name extension for that language.|
3434
|`OutputDirectory`|Optional <xref:Microsoft.Build.Framework.ITaskItem> parameter.<br /><br /> Specifies the destination folder for the generated code, typically the intermediate folder.|
35-
|`OutputFile`|Optional <xref:Microsoft.Build.Framework.ITaskItem> output parameter.<br /><br /> Specifies the path of the file that was generated. If this parameter is set by using a file name, the destination folder is prepended to the file name. If it is set by using a root, the destination folder is ignored.<br /><br /> If this parameter is not set, the output file name is the destination folder, an arbitrary file name, and the default file name extension for the specified language.|
35+
|`OutputFile`|Optional <xref:Microsoft.Build.Framework.ITaskItem> output parameter.<br /><br /> Specifies the path of the file that was generated. If this parameter is set by using a file name, the destination folder is prepended to the file name. If it's set by using a root, the destination folder is ignored.<br /><br /> If this parameter isn't set, the output file name is the destination folder, an arbitrary file name, and the default file name extension for the specified language.|
3636

3737
## Remarks
3838

39-
In addition to having the parameters that are listed in the table, this task inherits parameters from the <xref:Microsoft.Build.Tasks.TaskExtension> class, which itself inherits from the <xref:Microsoft.Build.Utilities.Task> class. For a list of these additional parameters and their descriptions, see [TaskExtension base class](../msbuild/taskextension-base-class.md).
39+
In addition to having the parameters that are listed in the table, this task inherits parameters from the <xref:Microsoft.Build.Tasks.TaskExtension> class, which itself inherits from the <xref:Microsoft.Build.Utilities.Task> class. For a list of these additional parameters and their descriptions, see [TaskExtension base class](../msbuild/taskextension-base-class.md).
40+
41+
In MSBuild 17.7 and later, this task was updated to support a greater variety of parameter types for assembly-level attributes. MSBuild 17.6 and earlier supported only `String` as a parameter type for assembly-level attributes. With MSBuild 17.7 and later, you can construct any .NET assembly attribute, not only those whose parameters were string types, as in earlier versions of MSBuild.
42+
43+
For example, to define the assembly-level attribute `CLSCompliant(true)`, which uses a Boolean parameter, you can use the following syntax:
44+
45+
```xml
46+
<ItemGroup>
47+
<AssemblyAttribute Include="System.CLSCompliantAttribute">
48+
<_Parameter1>true</_Parameter1>
49+
</AssemblyAttribute>
50+
</ItemGroup>
51+
```
52+
53+
The code generated depends on the target language. For C#, it would be as follows:
54+
55+
```csharp
56+
[assembly: System.CLSCompliantAttribute(true)]
57+
```
58+
59+
Types defined in `mscorlib` are automatically inferred, such as Boolean in the previous example. You can define metadata of the form `{parameter}_TypeName` to specify types that can't be inferred.
60+
61+
```xml
62+
<ItemGroup>
63+
<AssemblyAttribute Include="Microsoft.Owin.OwinStartup">
64+
<_Parameter1>Microsoft.Examples.Startup</_Parameter1>
65+
<_Parameter1_TypeName>System.Type</_Parameter1_TypeName>
66+
</AssemblyAttribute>
67+
</ItemGroup>
68+
```
69+
70+
The code generated in C# is as follows:
71+
72+
```csharp
73+
[assembly: Microsoft.Owin.OwinStartup(typeof(Microsoft.Examples.Startup))]
74+
```
75+
76+
For more complicated parameter values, you can use the `{parameter}_IsLiteral`.
77+
78+
```xml
79+
<ItemGroup>
80+
<AssemblyAttribute Include="NUnit.Framework.Parallelizable">
81+
<_Parameter1>NUnit.Framework.ParallelScope.Fixtures</_Parameter1>
82+
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
83+
</AssemblyAttribute>
84+
</ItemGroup>
85+
```
86+
87+
The previous example produces the following assembly attribute in C#:
88+
89+
```output
90+
[assembly: NUnit.Framework.Parallelizable(NUnit.Framework.ParallelScope.Fixtures)]
91+
```
92+
93+
You can use any syntax that would normally be allowed in an attribute declaration in the language of the project. For an array parameter, you can use code like the following:
94+
95+
```xml
96+
<ItemGroup>
97+
<AssemblyAttribute Include="TestAttribute">
98+
<_Parameter1>new int[] { 1, 3, 5 } /* odd numbers */</_Parameter1>
99+
<_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
100+
</AssemblyAttribute>
101+
</ItemGroup>
102+
```
103+
104+
When you use `IsLiteral`, the syntax is interpreted by the appropriate compiler, and is therefore language-specific. If you have situations where more than one language share the same MSBuild import files and/or project files, you might need to use conditional syntax to ensure the code compiles with the relevant project-specific language.
40105

41106
## See also
42107

docs/version-control/git-clone-repository.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.custom: version-control
1515

1616
[!INCLUDE [Visual Studio](~/includes/applies-to-version/vs-windows-only.md)]
1717

18-
Visual Studio makes it easy to clone a repository right from the IDE. You can work remotely with the Git provider of your choice, such as GitHub or Azure DevOps.
18+
Visual Studio makes it easy to clone a repository right from the IDE. You can work remotely with the Git provider of your choice, such as GitHub or Azure DevOps. If you need to create a new repository instead of cloning an existing one, see [Create a repository from Visual Studio](git-create-repository.md).
1919

2020
## Prerequisites
2121

subscriptions/vscloud-billing-faq.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
ms.author: amast
66
manager: shve
77
ms.assetid: 21e0471d-ad59-4d21-9c6f-13f7147569af
8-
ms.date: 03/28/2023
8+
ms.date: 08/02/2023
99
ms.topic: conceptual
1010
description: Billing questions for cloud subscriptions.
1111

@@ -86,8 +86,8 @@ sections:
8686
How are annual cloud subscription charges processed?
8787
answer: |
8888
At each purchase, we bill the full quantity purchased immediately. Charges aren't spread over the year and there's no prorating. If you buy annual cloud subscriptions
89-
at different times in the year, you'll have subscriptions renewing in different months. We don't make all of a customer's annual cloud subscriptions coterminothere's
90-
common with Microsoft volume licensing agreement purchasing.
89+
at different times in the year, you'll have subscriptions renewing in different months. We don't make all of a customer's annual cloud subscriptions coterminous
90+
in the way that's common with Microsoft volume licensing agreement purchasing.
9191
9292
- question: |
9393
How do cancellations work?

0 commit comments

Comments
 (0)