Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.5: Error 'ThisAssembly.Git' is inaccessible due to its protection level #273

Closed
cmiles opened this issue Mar 24, 2023 · 24 comments
Labels

Comments

@cmiles
Copy link

cmiles commented Mar 24, 2023

Describe the Bug

In an existing project using version 2.3.0 without problems upgrading to 3.0.5 results in the error 'ThisAssembly.Git' is inaccessible due to its protection level.

I see the same error in a new Console Project adding 3.0.5 - it also reports 'The name 'IsDirtyString' does not exist in the current context'.

Steps to Reproduce

Create a new Console App
Add GitInfo 3.0.5
Add Console.WriteLine(ThisAssembly.Git.Commit); to the Program.cs
Rebuild the solution (with both new and upgraded projects I tried deleting the bin and obj folders/clean/rebuild with the same results)
I show the errors:

  • 'ThisAssembly.Git' is inaccessible due to its protection level
  • 'The name 'IsDirtyString' does not exist in the current context'

Expected Behavior

In the project I upgraded to 3.0.5 I wasn't seeing any errors with 2.3.0.

Version Info

GitInfo Version 3.0.5
VS 2022 Preview, Version 17.6.0 Preview 2.0
net7.0
Windows 11

Additional Info

In the existing project I upgraded it was a bit difficult to be completely sure that the GitInfo package was the likely source of the error so quickly tried new Console projects - cmiles/GitInfoV3BugExperiment.

I did see #92 but adding 'public partial class ThisAssembly { }' in the root namespace didn't seem to have an impact - I haven't had to do that in the past.

Great project!!! Thanks for any help!!!!

@cmiles cmiles added the bug label Mar 24, 2023
@digitalsigi
Copy link

same here.

Using gitinfo for quit some time now. Geat stuff!

@larcai
Copy link

larcai commented Mar 27, 2023

same issue here

@walcholi
Copy link

Same for me since I updated from 2.3.0 to 3.0.5

Project:

  • .NET 6 .0
  • Windows target
  • WPF project

@tobsil
Copy link

tobsil commented Mar 29, 2023

Ran into the same issue. It's working with with version 3.0.4

@JonathanWheelhouse
Copy link

JonathanWheelhouse commented Apr 3, 2023

This is a great package, thanks for your work.

Got the same issue. i.e.
error CS0103: The name 'IsDirtyString' does not exist in the current context
error CS0122: 'ThisAssembly.Git' is inaccessible due to its protection level

Project is C# BlazorWasm self hosted .NET 7

@enegs
Copy link

enegs commented Apr 4, 2023

Ran into the same issue. It's working with with version 3.0.4

Same here
Also working in 3.0.4, too but seems that IsDirty does not work (always false).

@emroark
Copy link

emroark commented Apr 7, 2023

Had the same problem. Got it working again by adding

<ThisAssemblyNamespace>System.Reflection</ThisAssemblyNamespace>

But this is pretty ugly, generates the ThisAssembly into the System.Reflection namespace, and at least one comment in a .targets file says that ThisAssemblyNamespace is unsupported. That said, it works for me, mostly because I already had a using System.Reflection; statement in my AssemblyInfo.cs file.

@luucasgb
Copy link

Got the same problem. Going to try the solution by @emroark

Had the same problem. Got it working again by adding

<ThisAssemblyNamespace>System.Reflection</ThisAssemblyNamespace>

@AndrewOsman
Copy link

@luucasgb

Where does one add
<ThisAssemblyNamespace>System.Reflection</ThisAssemblyNamespace>

@GregEakin
Copy link

@AndrewOsman, In the csproj file, like this:

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ThisAssemblyNamespace>System.Reflection</ThisAssemblyNamespace>
  </PropertyGroup>

@ax-meyer
Copy link

Having the same problem here, blocking me from upgrading im multiple projects.

@OkkeHendriks
Copy link

So 3.0.5 gives me the same error, I have to downgrade to 2.3.0 in order to make it work again,
I have no custom settings, just installed the nuget package.

FYI, the mentioned workaround does work (with 3.0.5) during debug/release build for me, but not during publish?

<ThisAssemblyNamespace>System.Reflection</ThisAssemblyNamespace>

Used publish profile:

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishProtocol>FileSystem</PublishProtocol>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <PublishDir>bin\Release\netcoreapp3.0\publish\</PublishDir>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
    <PublishReadyToRun>false</PublishReadyToRun>
  </PropertyGroup>
</Project>

@kzu
Copy link
Member

kzu commented May 5, 2023

I pushed a fix, which is available as 3.0.6 which should also solve this. Sorry folks! Could you please verify the fix?

Closed by #282

@kimimaru4000
Copy link

kimimaru4000 commented May 5, 2023

I'm still getting this error message in VSCodium with GitInfo 3.0.6, though I can compile. IsDirty is still returning false when it shouldn't.

@kzu
Copy link
Member

kzu commented May 9, 2023

This issue is for the build error. Please open a new one for incorrect value for IsDirty, perhaps. That would need a full binlog for diagnostics. You can check what git commands are being executed and run them yourself manually and see if you get the same dirty/non-dirty behavior via CLI. It might be some git config setting that's actually causing the value to be unexpected.

@kzu kzu closed this as completed May 9, 2023
@enegs
Copy link

enegs commented May 9, 2023

This issue is for the build error. Please open a new one for incorrect value for IsDirty, perhaps. That would need a full binlog for diagnostics. You can check what git commands are being executed and run them yourself manually and see if you get the same dirty/non-dirty behavior via CLI. It might be some git config setting that's actually causing the value to be unexpected.

I'm going to make some tests, too but I faced the same issue with version 3.x. I didn't really test at that time because of the #273 issue preventing test but I remember IsDirty not working.

@Saibamen
Copy link

Upgraded from 2.3.0 to 3.3.3 and I have this same problem

@enegs
Copy link

enegs commented Sep 27, 2023

I can't confirm for now because i'm still in 3.3.1 (with correct behavior, btw).

@digitalsigi
Copy link

I can confirm: 3.3.3 is working. I would recommend to delete all bin & obj folders in this projects and run a clean project.

@Saibamen
Copy link

@digitalsigi: It was fresh build via Azure DevOps (msbuild.exe)

@FanDjango
Copy link

Create a new Console App Net Framework Non-SDK
Add GitInfo 2.3.0
Add Console.WriteLine(ThisAssembly.Git.Commit); to the Program.cs
Works fine.

Upgrade to GitInfo 3.3.3

Result:
'ThisAssembly.Git' is inaccessible due to its protection level

Tried the same sequence with a new Console APP, this time using SDK style .csproj, then GitInfo 3.3.3 is OK.

@kzu
Copy link
Member

kzu commented Dec 17, 2023

Non-SDK style is for all intents and purposes, legacy stuff.

I'm open to a PR if you figure out why it fails, but otherwise, this won't be actively worked on.

@FanDjango
Copy link

FanDjango commented Dec 17, 2023

I suppose this is also re. #326 which I will now close.

That's ok. It took me a while to find this out - so now others can save some time if they stumble across this issue.

It was easy to externalize the GitInfo methods into a separate SDK project and invoke those from the original non-SDK project.

@kzu
Copy link
Member

kzu commented Jan 30, 2024

I guess I could try issuing a more intuitive build error for that scenario.

Also, you could also create a partial class and make the relevant types public to avoid that? 🤔

BardezAnAvatar added a commit to BardezAnAvatar/Sots.Sots1.SavedGameEditor that referenced this issue May 14, 2024
BardezAnAvatar added a commit to BardezAnAvatar/Sots.Sots1.SavedGameEditor that referenced this issue May 17, 2024
* ci: do not fail if no new version, warning is sufficient

* chore: use latest language verion in csproj files

* chore: disable AssemblyInfo auto-generation

* Chore: clean up csproj files

* chore: install GitInfo NuGet package

* chore: consum GitInfo for AssemblyInfo file gen

* chore: clean up spaces for file dirs

* chore: remove old version

* Use the GitInfo to display the app version

* ci: build with the release tag

* ci: rovide friendly names on PR steps

* ci: Fix published ZIP folder structure

* ci: Fix the targeted solution file

* ci: fix the build solution file

* ci: Rename the generated ZIP files

* ci: Encountered an MSBuild issue, so mitigate in MSBuild csproj?

* ci: Try forcing the codegen

* ci: let's try spinning

* CI: only gen ThisAssembly on the one project

* CI: try this
devlooped/GitInfo#273

* CI: Remove branch name for cleanliness

* CI: set version and such

* CI: drop this

* try stuff

* CI: downgrade

* CI: fetch tags

* Screw around with GitVersion/GitTools

* Install GitVersion.MsBuild

* Uninstall GitInfo

* Removing GitVersion cruft

* check PR for valid labels and stuff

* move around params

* attempt to update SemVer with main

* changing how the version is retrieved

* CI refused a list

* CI refuses a list

* MergeMessageOnly

* Finally hit my intended versioning scheme

* Update to display regular versionon merge

* add labeles

* add in "edited"

* Give step a name

* cancel in progress
BardezAnAvatar added a commit to BardezAnAvatar/Sots.Sots1.SavedGameEditor that referenced this issue May 17, 2024
* ci: do not fail if no new version, warning is sufficient

* chore: use latest language verion in csproj files

* chore: disable AssemblyInfo auto-generation

* Chore: clean up csproj files

* chore: install GitInfo NuGet package

* chore: consum GitInfo for AssemblyInfo file gen

* chore: clean up spaces for file dirs

* chore: remove old version

* Use the GitInfo to display the app version

* ci: build with the release tag

* ci: rovide friendly names on PR steps

* ci: Fix published ZIP folder structure

* ci: Fix the targeted solution file

* ci: fix the build solution file

* ci: Rename the generated ZIP files

* ci: Encountered an MSBuild issue, so mitigate in MSBuild csproj?

* ci: Try forcing the codegen

* ci: let's try spinning

* CI: only gen ThisAssembly on the one project

* CI: try this
devlooped/GitInfo#273

* CI: Remove branch name for cleanliness

* CI: set version and such

* CI: drop this

* try stuff

* CI: downgrade

* CI: fetch tags

* Screw around with GitVersion/GitTools

* Install GitVersion.MsBuild

* Uninstall GitInfo

* Removing GitVersion cruft

* check PR for valid labels and stuff

* move around params

* attempt to update SemVer with main

* changing how the version is retrieved

* CI refused a list

* CI refuses a list

* MergeMessageOnly

* Finally hit my intended versioning scheme

* Update to display regular versionon merge

* add labeles

* add in "edited"

* Give step a name

* cancel in progress

* Revert to main, I'll screw around as needed

-- begin release notes --
Adding SemVer calculation to CI
-- end release notes --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests