2

I have created a class Library, which has some static classes with const strings, which are serving some common strings* for the assembly attributes:

//Assembly: Conwell.Manifest
namespace Conwell.Manifest.AssemblyInfos
{
    public static class AdministrationAssemblyInfo
    {
        public const string Company = "Foo";
        public const string Trademark = "Bar";
        public const string Copyright = "Baz";
        public const string AssemblyVersion = "1.0.*";
        public const string ProductName = "Administration";
    }
}

In my MVC Project I have this AssemblyInfo:

//Assembly: Conwell.Administration Properties:AssemblyInfo.cs
using System.Reflection;
using System.Runtime.InteropServices;
using Conwell.Manifest.AssemblyInfos;

// CLR Attributes
[assembly: ComVisible(false)]
[assembly: Guid("16abe67b-6992-4a20-83bb-decad83600f0")]
[assembly: AssemblyVersion(AdministrationAssemblyInfo.AssemblyVersion)]
[assembly: AssemblyCulture("")]
[assembly: AssemblyConfiguration("")]

// Informational Attributes
[assembly: AssemblyCompany(AdministrationAssemblyInfo.Company)]
[assembly: AssemblyCopyright(AdministrationAssemblyInfo.Copyright)]
[assembly: AssemblyTitle(AdministrationAssemblyInfo.ProductName)]
[assembly: AssemblyDescription(AdministrationAssemblyInfo.ProductName)]
[assembly: AssemblyProduct(AdministrationAssemblyInfo.ProductName)]
[assembly: AssemblyTrademark(AdministrationAssemblyInfo.Trademark)]

This compiles fine in Debug and Release Mode.

I just tried to publish the whole project, and encountered an error I do not realy unterstand:

The type or namespace name 'Conwell' could not be found (are you missing a using directive or an assembly reference?)

Published failed

The tmp file contains this:

18.03.2018 23:59:18
System.AggregateException: One or more errors occurred. ---> System.Exception: Publish failed due to build errors. Check the error list for more details.
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass40_0.<PublishAsync>b__2()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- 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 Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__108.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors. Check the error list for more details.<---

===================

The output is this:

13>------ Publish started: Project: Conwell.Administration, Configuration: Release Any CPU ------
13>Connecting to D:\IIS\Test...
13>Transformed Web.config using D:\Dev\Conwell\OnlineSystem\Dev\Conwell.Administration\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
13>Copying all files to temporary location below for package/publish:
13>obj\Release\AspnetCompileMerge\Source.
13>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v / -p D:\Dev\Conwell\OnlineSystem\Dev\Conwell.Administration\obj\Release\AspnetCompileMerge\Source -c D:\Dev\Conwell\OnlineSystem\Dev\Conwell.Administration\obj\Release\AspnetCompileMerge\TempBuildDir 
13>d:\Dev\Conwell\OnlineSystem\Dev\Conwell.Administration\obj\Release\AspnetCompileMerge\Source\Areas\Global\Views\Help\Info.cshtml(15,0): Warning CS0618: 'Conwell.Administration.Core.Service.ConfigurationService' ist veraltet: 'Methoden in SystemSettings Service implementieren!'
13>d:\Dev\Conwell\OnlineSystem\Dev\Conwell.Administration\obj\Release\AspnetCompileMerge\Source\Views\Shared\Layout.cshtml(34,0): Warning CS0618: 'Conwell.Administration.Core.Service.ConfigurationService' ist veraltet: 'Methoden in SystemSettings Service implementieren!'
13>d:\Dev\Conwell\OnlineSystem\Dev\Conwell.Administration\obj\Release\AspnetCompileMerge\Source\Views\Shared\LayoutPublic.cshtml(45,0): Warning CS0618: 'Conwell.Administration.Core.Service.ConfigurationService' ist veraltet: 'Methoden in SystemSettings Service implementieren!'
13>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe /out:obj\Release\AssemblyInfo\AssemblyInfo.dll /target:library Properties\AssemblyInfo.cs
13>Properties\AssemblyInfo.cs(8,28): Error CS0103: The name 'AdministrationAssemblyInfo' does not exist in the current context
13>Properties\AssemblyInfo.cs(13,28): Error CS0103: The name 'AdministrationAssemblyInfo' does not exist in the current context
13>Properties\AssemblyInfo.cs(14,30): Error CS0103: The name 'AdministrationAssemblyInfo' does not exist in the current context
13>Properties\AssemblyInfo.cs(15,26): Error CS0103: The name 'AdministrationAssemblyInfo' does not exist in the current context
13>Properties\AssemblyInfo.cs(16,32): Error CS0103: The name 'AdministrationAssemblyInfo' does not exist in the current context
13>Properties\AssemblyInfo.cs(17,28): Error CS0103: The name 'AdministrationAssemblyInfo' does not exist in the current context
13>Properties\AssemblyInfo.cs(18,30): Error CS0103: The name 'AdministrationAssemblyInfo' does not exist in the current context
13>Properties\AssemblyInfo.cs(3,7): Error CS0246: The type or namespace name 'Conwell' could not be found (are you missing a using directive or an assembly reference?)

The warnings are basicly some custom ones, using ObsoleteAttribute.

Has this something todo with enabled precompilation?

What I have tried so far:

  • Creating a static method in my AdministrationAssemblyInfo, calling Console.WriteLine. This method I have called from global.asax in order to preclude any optimization, since all the library contains are const.
  • Clean Solution
  • Restart PC

I have absolute no clue, what is causing the issue.

* my main motivation is to have a single location for changing the version, since I use a lot of class libraries

Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
  • Looks like Visual Studio/msbuild issue – Evgeny Gorbovoy Mar 18 '18 at 23:42
  • Just confirming that `AdministrationAssemblyInfo` **isn't** in a `namespace`? –  Mar 18 '18 at 23:51
  • It is, see my update. But I am also using it in the `AssemblyInfo` file @MickyD – Christian Gollhardt Mar 18 '18 at 23:54
  • 1
    FYI - With the [new `.csproj` format](https://stackoverflow.com/a/48677981), you can now have most assembly attributes generated based on the project file so you don't have to deal with these attributes. See [this question](https://stackoverflow.com/q/42138418). Note that you can make "common assembly info" by importing attributes from a common MSBuild file like ``. – NightOwl888 Mar 18 '18 at 23:58
  • Thank you for this info. I will definitive consider this in newer .net core project. But according to [this article](https://www.natemcmaster.com/blog/2017/03/09/vs2015-to-vs2017-upgrade/) this does not work for `MVC5` applications, does it? @NightOwl888 – Christian Gollhardt Mar 19 '18 at 00:03
  • Yea, you are right, I guess that isn't ready. I was able to provide support for .NET Framework class libraries just fine, but I suppose not all of the features will work in ASP.NET/MVC. – NightOwl888 Mar 19 '18 at 00:17

0 Answers0