When you create a project, Visual Studio sets it up to compile & generate a corresponding assembly. Each project generates 1 assembly, and so each has a corresponding assembly configuration to generate its assembly from.
The problem is when you create more than one project that each can generate their own assembly, and then include one of these projects in the other.
In this scenario, Visual Studio gets confused and doesn’t know which config file to go off of to generate the single assembly for the project — it finds the second assembly configuration in the included project and says «HEY, DUPLICATE! You’ve given me two sets of instructions for generating my assembly!»
But sometimes you still want the included project to be able to generate an assembly on it’s own, but not when it is being included in another project.
To obtain this, one solution is to add conditional defines to the including project (found in project Properties). Then change the assembly config in the included project to look for this conditional define. If it is defined (by the including project), then the config can skip over it’s content — this will result in only 1 config found by VS — the one from the including project — problem solved!
Steps Below (screenshots included)
Step 1: Select the including/container Project > Right Click > Properties
Project properties (screenshot)
Step 2: Navigate to Build > General > Conditional compilation symbols
Add your conditional defines as shown:
Conditional compilation symbols (screenshot)
Step 3: Use conditional defines in the included project AssemblyInfo.cs
Using conditional defines (screenshot)
@piotrpMSFT I tried suggested solution with adding Exclude
to Compile
section and getting following crash:
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.Shared.FileMatcher.GetFiles(String projectDirectoryUnescaped, String filespecUnescaped, IEnumerable`1 excludeSpecsUnescaped, GetFileSystemEntries getFileSystemEntries, DirectoryExists directoryExists)
at Microsoft.Build.Internal.EngineFileUtilities.GetFileList(String directoryEscaped, String filespecEscaped, Boolean returnEscaped, IEnumerable`1 excludeSpecsEscaped)
at Microsoft.Build.Evaluation.LazyItemEvaluator`4.IncludeOperation.SelectItems(Builder listBuilder, ImmutableHashSet`1 globsToIgnore)
at Microsoft.Build.Evaluation.LazyItemEvaluator`4.LazyItemOperation.Apply(Builder listBuilder, ImmutableHashSet`1 globsToIgnore)
at Microsoft.Build.Evaluation.LazyItemEvaluator`4.MemoizedOperation.Apply(Builder listBuilder, ImmutableHashSet`1 globsToIgnore)
at Microsoft.Build.Evaluation.LazyItemEvaluator`4.LazyItemList.ComputeItems(LazyItemList lazyItemList, ImmutableHashSet`1 globsToIgnore)
at Microsoft.Build.Evaluation.LazyItemEvaluator`4.LazyItemList.GetItems(ImmutableHashSet`1 globsToIgnore)
at Microsoft.Build.Evaluation.LazyItemEvaluator`4.<>c.<GetAllItems>b__22_0(LazyItemList itemList)
at System.Linq.Enumerable.<SelectManyIterator>d__157`2.MoveNext()
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.OrderedEnumerable`1.ToList()
at Microsoft.Build.Evaluation.LazyItemEvaluator`4.GetAllItems()
at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
at Microsoft.Build.Execution.ProjectInstance.Initialize(ProjectRootElement xml, IDictionary`2 globalProperties, String explicitToolsVersion, String explicitSubToolsetVersion, Int32 visualStudioVersionFromSolution, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Execution.ProjectInstance..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, BuildParameters buildParameters, ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.BackEnd.RequestBuilder.LoadProjectIntoConfiguration()
at Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__57.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.Build.BackEnd.RequestBuilder.<BuildAndReport>d__49.MoveNext()
MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean debugger, Boolean detailedSummary)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.CommandLine.MSBuildApp.BuildProject(String projectFile, String[] targets, String toolsVersion, Dictionary`2 globalProperties, ILogger[] loggers, LoggerVerbosity verbosity, DistributedLoggerRecord[] distributedLoggerRecords, Int32 cpuCount, Boolean enableNodeReuse, TextWriter preprocessWriter, Boolean debugger, Boolean detailedSummary)
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args)
UPDATED: 2020-12-23
I’ll leave the below for posterity, but recently I came across the real reason for the error. In this issue it was pointed out that your .net core solutions have to be structured in a particular way. Specifically, make sure that you do not create projects in the same directory as your main project.
Problem description
I recently started working on my first .NET Core project and quickly ran into a problem. After adding a class library project, the second time I ran dotnet run
I received the following errors:
error CS0579: Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ attribute
error CS0579: Duplicate ‘System.Reflection.AssemblyConfigurationAttribute’ attribute
error CS0579: Duplicate ‘System.Reflection.AssemblyFileVersionAttribute’ attribute
error CS0579: Duplicate ‘System.Reflection.AssemblyInformationalVersionAttribute’ attribute
error CS0579: Duplicate ‘System.Reflection.AssemblyProductAttribute’ attribute
error CS0579: Duplicate ‘System.Reflection.AssemblyTitleAttribute’ attribute
error CS0579: Duplicate ‘System.Reflection.AssemblyVersionAttribute’ attribute
tl;dr Solution
My Google-fu revealed the solution buried in a GitHub issue thread. Add the following line to your *.csproj
files:
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
As the name indicates, this will prevent the build process from generating the AssemblyInfo.cs file in project obj
directories, thus preventing the duplicate attribute conflict.
Details
Disclaimer: I am far from a .NET expert so there is probably more to this story.
The error is a result of the build process generating AssemblyInfo.cs
files in each project obj
directory. This file exists to provide MSBuild metadata about the resulting assembly that can be attached to the build artifact and utilized by anyone who wants such information. You can see your assembly info in Windows by selecting your build artifact, right click -> properties. The following shows the results with GenerateAssemblyInfo set to false. As you can see, the metadata is set to default values.
It’s not clear why the default .csproj
file generated by dotnet new
results in this behavior. The closest I came across was a mention of the philosophy to keep the file as terse as possible. Of course, I’m completely in support of this as .csproj
tends to be a dense mess in Visual Studio. However, this particular scenario puts the onus on the developer to edit the file to eliminate an error which is almost guaranteed to occur in a project of any complexity. A better design decision would have probably been to default to not generating AssemblyInfo.cs
.
Содержание
- CS0579 Duplicate Attribute Error with .NET Core
- Problem description
- tl;dr Solution
- Details
- Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ attribute
- Resolution
- Wrapping up
- dotnet test result an error CS0579: Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ #4837
- Comments
- error CS0579: Duplicate ‘global::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute #12297
- Comments
- build error from artifact (Duplicate attribute in AssemblyInfo.cs) #93
- Comments
CS0579 Duplicate Attribute Error with .NET Core
I’ll leave the below for posterity, but recently I came across the real reason for the error. In this issue it was pointed out that your .net core solutions have to be structured in a particular way. Specifically, make sure that you do not create projects in the same directory as your main project.
Problem description
I recently started working on my first .NET Core project and quickly ran into a problem. After adding a class library project, the second time I ran dotnet run I received the following errors:
error CS0579: Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ attribute error CS0579: Duplicate ‘System.Reflection.AssemblyConfigurationAttribute’ attribute error CS0579: Duplicate ‘System.Reflection.AssemblyFileVersionAttribute’ attribute error CS0579: Duplicate ‘System.Reflection.AssemblyInformationalVersionAttribute’ attribute error CS0579: Duplicate ‘System.Reflection.AssemblyProductAttribute’ attribute error CS0579: Duplicate ‘System.Reflection.AssemblyTitleAttribute’ attribute error CS0579: Duplicate ‘System.Reflection.AssemblyVersionAttribute’ attribute
tl;dr Solution
My Google-fu revealed the solution buried in a GitHub issue thread. Add the following line to your *.csproj files:
As the name indicates, this will prevent the build process from generating the AssemblyInfo.cs file in project obj directories, thus preventing the duplicate attribute conflict.
Details
Disclaimer: I am far from a .NET expert so there is probably more to this story.
Источник
Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ attribute
As part of my research into IdentityServer4 I forked their samples repo, but I ran into the following issue trying to build the solution for the Client Credentials quickstart.
CS0579 Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyConfigurationAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyProductAttribute’ attribute
Searching the project each of these attributes only exists only in the AssemblyInfo.cs file found under properties. It turns out the file that is causing the issues only exists as a result of the build process and is found in the objDebugnetcoreapp1.1.AssemblyInfo.cs file.
In this case, the client project is a console application so I created a new console application and the template no longer generates an AssemblyInfo.cs file for .NET Core. It turns out that as part of the move back to csproj most of the information that was in the AssemblyInfo.cs can now be set on the project its self. Open the project properties and select the Package tab to see the new settings.
Resolution
I found this issue on GitHub where there were a couple of options to resolve this issue which I am going to cover here plus a third option I tried not mention in the issue.
Option one is to remove the conflicting items from the AssemblyInfo.cs file. For example, the following would allow the project I am working with to build.
Option two is to edit the csproj and turn the generation of the attributes causing the issues off.
The third option is to total delete the AssemblyInfo.cs file if your project doesn’t need it. This is the option I chose to go with. For a reason, you might want to keep the file around and just use option one see the “AssemblyInfo.cs is partially dead” section of this post by Muhammad Rehan Saeed. Side note: if you are interested in ASP.NET Core and you aren’t following Rehan you really should be.
Wrapping up
This is an issue that you will really only face when converting an older project to .NET Core. The fix is simple enough once you know what is going on. I opened an issue on the IdentityServer samples if you want to track if this has been fixed yet.
Источник
dotnet test result an error CS0579: Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ #4837
Hi,
When building my project under Azure Devops yaml pipeline, if I launch unit test in my Dockerfile, I get the following :
error CS0579: Duplicate ‘System.Reflection.AssemblyCompanyAttribute’
The project is like organised this way
So my Unit test (xUnit) project is under tests folder of my main project within the same repository.
My Dockerfile used for my CICD is
I both ITF.Microservices.Ordering.csproj and ITF.Microservices.Ordering.UnitTests.csproj I added the following to get rid of Duplicate errors.
Under Azure Devops I use the following pipeline
And the following build_deploy.yml template
The pipeline does build and publish the release correctly, but when I require dotnet test instruction from the Dockerfile, the tests are played and published
But it ended with an error
Full error line here
obj/Release/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘global::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute [/src/src/ITF.Microservices.Ordering/ITF.Microservices.Ordering.csproj]
When I remove the dotnet test from the Dockerfile instruction, everything works fine
Some people seem to face the same problem as me
https://stackoverflow.com/a/62021598/4734707
The text was updated successfully, but these errors were encountered:
Источник
error CS0579: Duplicate ‘global::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute #12297
Hello, I am working on a SDK where we have multiple build targets. I have been running into an issue where each of the targets seems to be building assembly attributes when I have explicitly turned them off with
In the main property group of every csproj file
Here is the errors I am seeing:
net45objDebug.NETFramework,Version=v4.5.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘global::System.Runtime. Versioning.TargetFrameworkAttribute’ attribute [dropbox-sdk-dotnetdropbox-sdk-dotnetDropbox.Api Dropbox.Api.NetStandard.csproj] net45objRelease.NETFramework,Version=v4.5.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘global::System.Runtim e.Versioning.TargetFrameworkAttribute’ attribute [dropbox-sdk-dotnetdropbox-sdk-dotnetDropbox.Ap iDropbox.Api.NetStandard.csproj] portable40objDebug.NETPortable,Version=v4.0,Profile=Profile344.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘ global::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute [dropbox-sdk-dotnetdropbox- sdk-dotnetDropbox.ApiDropbox.Api.NetStandard.csproj] portable40objRelease.NETPortable,Version=v4.0,Profile=Profile344.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘global::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute [dropbox-sdk-dotnetdropbo x-sdk-dotnetDropbox.ApiDropbox.Api.NetStandard.csproj] portableobjDebug.NETPortable,Version=v4.5,Profile=Profile111.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘gl obal::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute [dropbox-sdk-dotnetdropbox-sd k-dotnetDropbox.ApiDropbox.Api.NetStandard.csproj] portableobjRelease.NETPortable,Version=v4.5,Profile=Profile111.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘ global::System.Runtime.Versioning.TargetFrameworkAttribute’ attribute [dropbox-sdk-dotnetdropbox- sdk-dotnetDropbox.ApiDropbox.Api.NetStandard.csproj] objReleasenetstandard2.0.NETStandard,Version=v2.0.AssemblyAttributes.cs(4,12): error CS0579: Duplicate ‘global::Syst em.Runtime.Versioning.TargetFrameworkAttribute’ attribute [dropbox-sdk-dotnetdropbox-sdk-dotnetD ropbox.ApiDropbox.Api.NetStandard.csproj]
I am not sure if I am generating this incorrectly or if there is another way to disable this error.
For more information, I am working on the Dropbox SDK
The text was updated successfully, but these errors were encountered:
Источник
build error from artifact (Duplicate attribute in AssemblyInfo.cs) #93
.NET Core Version: (e.g. 3.0 Preview1, or daily build number, use dotnet —info )
3.0.100-preview-009750
Windows version: ( winver )
Version 1809 (OS Build 17763.134)
Does the bug reproduce also in WPF for .NET Framework 4.8?: No
Problem description:
When trying to build a basic WPF project for dotnet core 3.0 I get multiple duplicate attribute errors that appear to be from a temporary file ( objDebugnetcoreapp3.0NetCoreWpf_xnekjbde_wpftmp.AssemblyInfo.cs ) conflicting with the actual AssemblyInfo.cs file
To get this error, after a fresh install of Visual Studio 2019 preview 1 I tried to open and build a wpf dotnet core project modified using Brian Lagunis’s instructions from his blog post here. The project is empty (was generated in Visual Studio 15.9.3)
Actual behavior:
6 duplicate attribute errors fail the build.
CS0579 Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyConfigurationAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyFileVersionAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyProductAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyTitleAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyVersionAttribute’ attribute
Expected behavior:
No duplicate attribute errors occur unless there are duplicate attributes in my project, in which case the error message should point to the human-made code where the error occurs.
The text was updated successfully, but these errors were encountered:
Источник
When you create a project, Visual Studio sets it up to compile & generate a corresponding assembly. Each project generates 1 assembly, and so each has a corresponding assembly configuration to generate its assembly from.
The problem is when you create more than one project that each can generate their own assembly, and then include one of these projects in the other.
In this scenario, Visual Studio gets confused and doesn’t know which config file to go off of to generate the single assembly for the project — it finds the second assembly configuration in the included project and says «HEY, DUPLICATE! You’ve given me two sets of instructions for generating my assembly!»
But sometimes you still want the included project to be able to generate an assembly on it’s own, but not when it is being included in another project.
To obtain this, one solution is to add conditional defines to the including project (found in project Properties). Then change the assembly config in the included project to look for this conditional define. If it is defined (by the including project), then the config can skip over it’s content — this will result in only 1 config found by VS — the one from the including project — problem solved!
Steps Below (screenshots included)
Step 1: Select the including/container Project > Right Click > Properties
Project properties (screenshot)
Step 2: Navigate to Build > General > Conditional compilation symbols
Add your conditional defines as shown:
Conditional compilation symbols (screenshot)
Step 3: Use conditional defines in the included project AssemblyInfo.cs
Using conditional defines (screenshot)
When you create a project, Visual Studio sets it up to compile & generate a corresponding assembly. Each project generates 1 assembly, and so each has a corresponding assembly configuration to generate its assembly from.
The problem is when you create more than one project that each can generate their own assembly, and then include one of these projects in the other.
In this scenario, Visual Studio gets confused and doesn’t know which config file to go off of to generate the single assembly for the project — it finds the second assembly configuration in the included project and says «HEY, DUPLICATE! You’ve given me two sets of instructions for generating my assembly!»
But sometimes you still want the included project to be able to generate an assembly on it’s own, but not when it is being included in another project.
To obtain this, one solution is to add conditional defines to the including project (found in project Properties). Then change the assembly config in the included project to look for this conditional define. If it is defined (by the including project), then the config can skip over it’s content — this will result in only 1 config found by VS — the one from the including project — problem solved!
Steps Below (screenshots included)
Step 1: Select the including/container Project > Right Click > Properties
Project properties (screenshot)
Step 2: Navigate to Build > General > Conditional compilation symbols
Add your conditional defines as shown:
Conditional compilation symbols (screenshot)
Step 3: Use conditional defines in the included project AssemblyInfo.cs
Using conditional defines (screenshot)
As part of my research into IdentityServer4 I forked their samples repo, but I ran into the following issue trying to build the solution for the Client Credentials quickstart.
CS0579 Duplicate ‘System.Reflection.AssemblyCompanyAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyConfigurationAttribute’ attribute
CS0579 Duplicate ‘System.Reflection.AssemblyProductAttribute’ attribute
Searching the project each of these attributes only exists only in the AssemblyInfo.cs file found under properties. It turns out the file that is causing the issues only exists as a result of the build process and is found in the objDebugnetcoreapp1.1{ProjectName}.AssemblyInfo.cs file.
In this case, the client project is a console application so I created a new console application and the template no longer generates an AssemblyInfo.cs file for .NET Core. It turns out that as part of the move back to csproj most of the information that was in the AssemblyInfo.cs can now be set on the project its self. Open the project properties and select the Package tab to see the new settings.
Resolution
I found this issue on GitHub where there were a couple of options to resolve this issue which I am going to cover here plus a third option I tried not mention in the issue.
Option one is to remove the conflicting items from the AssemblyInfo.cs file. For example, the following would allow the project I am working with to build.
Before: [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Client")] [assembly: AssemblyTrademark("")] After: [assembly: AssemblyTrademark("")]
Option two is to edit the csproj and turn the generation of the attributes causing the issues off.
Before: <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> <OutputType>Exe</OutputType> </PropertyGroup> After: <PropertyGroup> <TargetFramework>netcoreapp1.1</TargetFramework> <OutputType>Exe</OutputType> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> </PropertyGroup>
The third option is to total delete the AssemblyInfo.cs file if your project doesn’t need it. This is the option I chose to go with. For a reason, you might want to keep the file around and just use option one see the “AssemblyInfo.cs is partially dead” section of this post by Muhammad Rehan Saeed. Side note: if you are interested in ASP.NET Core and you aren’t following Rehan you really should be.
Wrapping up
This is an issue that you will really only face when converting an older project to .NET Core. The fix is simple enough once you know what is going on. I opened an issue on the IdentityServer samples if you want to track if this has been fixed yet.
Problem
You’re trying to add the AssemblyVersion attribute to your project, like this:
Code language: C# (cs)
using System.Reflection; [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
And you get the following compiler errors:
Error CS0579 Duplicate ‘AssemblyVersion’ attribute
Error CS0579 Duplicate ‘AssemblyFileVersion’ attribute
But you don’t see these attributes anywhere else in your project.
Solution
The problem is Visual Studio auto-generates the assembly info by default.
To turn this off, put the following in your .csproj file:
Code language: HTML, XML (xml)
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <PropertyGroup> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup> </Project>
Where is the auto-generated assembly info?
My assembly is called DupeAssemblyVersion and I’m targeting .NET Core 3.1. So the auto-generated assembly info file is here: objDebugnetcoreapp3.1DupeAssemblyVersion.AssemblyInfo.cs.
Here’s what this file looks like:
Code language: C# (cs)
//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ using System; using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("DupeAssemblyVersion")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] [assembly: System.Reflection.AssemblyProductAttribute("DupeAssemblyVersion")] [assembly: System.Reflection.AssemblyTitleAttribute("DupeAssemblyVersion")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] // Generated by the MSBuild WriteCodeFragment class.
- Remove From My Forums
-
Question
-
I have created a new GAT project. Removed all the existing projects which are shown by default in the Project.
I am adding a new project under Templates/Solutions/Projects/MyClassProject
This folder has a file Properties/AssemblyInfo.cs. When am compiling my solution I ma getting the following compile errors
Can someone help me understand why is this compiler errors seen? This AssemblyInfo.cs if my GAT project’s file and it seems to be clashing with Templates/Solutions/Projects/MyClassProject/Properties/AssemblyInfo.cs file.
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(31,12): error CS0579: Duplicate ‘AssemblyVersion’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(20,12): error CS0579: Duplicate ‘ComVisible’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(15,12): error CS0579: Duplicate ‘AssemblyCulture’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(14,12): error CS0579: Duplicate ‘AssemblyTrademark’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(13,12): error CS0579: Duplicate ‘AssemblyCopyright’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(12,12): error CS0579: Duplicate ‘AssemblyProduct’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(11,12): error CS0579: Duplicate ‘AssemblyCompany’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(10,12): error CS0579: Duplicate ‘AssemblyConfiguration’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(9,12): error CS0579: Duplicate ‘AssemblyDescription’ attribute
C:TempForDeleteRndTest_GuidancePackageMyApplicationPackageMyApplicationPackagePropertiesAssemblyInfo.cs(8,12): error CS0579: Duplicate ‘AssemblyTitle’ attribute
Answers
-
This is because you haven’t marked the .cs files you added as content files. You need to make sure the .cs files you add to the «Templates» folder are properly marked as «Build Action=Content» and «Copy To Output Directory=Copy If Newer» so they don’t get compiled with your solution (and classes don’t clash).
In GAT, there is a recipe for automating this setting, if you right-click on the «Templates» folder you should see it, I just don’t remember the exact name for it right now, sorry.
-vga.
-
When you right click on the «Templates» folder of your guidance package project you should get a menu option named «Set Content Files Build Properties», this is the recipe that will automatically set proper build properties for all the content files within that folder. If this option doesn’t appear please make sure that GAT is enabled for the solution you’re working on (go to Tools->Guidance Package Manager->Enable/Disable Packages and make sure Guidance Package Development is checked).
If you want to do this manually, you need to go to each file located within «Templates» folder, look at its properties (press F4) and set its «Build Action» property to «Content» and its «Copy To Output Directoy» as «Copy if newer».
HTH,
-vga.